Democrat Ralph Northam won Virginia’s race for governor Tuesday over Republican Ed Gillespie, as Democrats appeared headed for a big night across the board in races for lieutenant governor, attorney general and several key seats in the House of Delegates, based on exit polls and early returns.

Virginia’s election has been closely watched nationwide as a test of President Trump’s status and impact on the tenor of politics in every state.

From Korea, Trump wasted no time lashing out at Gillespie. “Ed Gillespie worked hard but did not embrace me or what I stand for,” the president tweeted before the final tally was in.

If those results held, it could signal a big win for Democrats in Virginia. Democrat Justin Fairfax appeared headed to win as lieutenant governor over Republican Jill Holtzman Vogel, and incumbent Attorney General Mark Herring was headed for re-election over Republican challenger John Adams.

The race had been close in pre-election polling, and Northam had been criticized by some in his own party for waging a low-key campaign in a time of high passion and sharp rhetoric. But Virginians turned out in large numbers on a day of patchy rain around the state as Northam and the Democrats relied on an increasingly efficient system for getting voters to the polls, especially in the more populous parts of the state.

Northam’s victory was propelled by white, college-educated women, voters who were concerned about health care, a strong showing among Democrats and voters who strongly disapprove of Trump, exit polls showed.

Northam was counting on high turnout in Virginia’s populous, diverse urban areas, particularly among African-American voters. Gillespie fought hard to eat into the growing Democratic base in Northern Virginia, as well as to motivate the largely rural, white voters who had supported Trump in last fall’s presidential race.

It was a tricky needle for Gillespie to thread. He had resisted even talking about the president for much of the race, while Northam called Trump a “narcissistic maniac” and pledged to be a bulwark against his policies in Virginia.

But Gillespie made a late pivot toward Trumpian tactics that seemed to energize his campaign, promising to defend Confederate heritage and airing ads that raised the specter of violence from illegal immigrants.

Trump, who never campaigned in Virginia for Gillespie, tweeted about the race several times Tuesday morning.

“Ralph Northam will allow crime to be rampant in Virginia,” Trump wrote on Twitter. If the Republican wins, Trump said, “MS-13 and crime will be gone.” He was referring to the MS-13 street gang that has featured prominently in Gillespie ads raising fears of violence and illegal immigration.

Those ads seemed to take a pivotal place in the race, appealing to some as an honest take on very real fears in suburban neighborhoods and condemned by others as Willie Horton-style race-baiting.

“I didn’t think any of the ads in any of the races were good. It was a race to the bottom,” said Morgan Broman, who is retired and accompanied his 18-year-old son as he voted for the first time at the Mt. Vernon Recreation Center in Alexandria. “Ralph Northam is not a member of MS-13 as far as I know.” Broman voted for the Democratic ticket.

The Trump factor drove an unusual amount of national attention toward Virginia, where the election was one of only two statewide contests in the country.