Updated at 11:44 p.m. ET

Democrat Ralph Northam has easily won the Virginia governor's race, defeating Republican Ed Gillespie in a stinging rebuke to President Trump.

The surprisingly early call in what was expected to be a much closer contest portended a very good night for Democrats in the Old Dominion and across the country. And one year after the 2016 presidential contest, Democrats finally got a signature victory after long boasting of rising opposition to Trump that hadn't paid off with wins in other high-profile races this year.

Polls in the final days had predicted a close race in Virginia, but ultimately Northam, the incumbent lieutenant governor, successfully rode an anti-Trump wave to victory over Gillespie's hard-line message on immigration and social issues. With nearly all votes in, Northam was besting Gillespie by about 9 points, higher than Hillary Clinton's 5-point win just last November.

Virginia Democrats also elected Justin Fairfax as lieutenant governor — just the second African-American elected to statewide office since Reconstruction — and re-elected Mark Herring as attorney general.

Trump quickly weighed in via Twitter, arguing Gillespie lost because he hadn't embraced him enough. Trump didn't campaign in person for Gillespie, though he did tweet out support for him and recorded a robocall saying the Republican candidate would help "make America great again."

The backlash to Trump wasn't limited just to the Virginia governor's mansion, however. Democrats are are poised to make major gains in the Virginia House of Delegates as well, including electing the country's first openly transgender state lawmaker, and with several races still too close to call control of the chamber could still switch hands. Democrat Danica Roem defeated Republican Bob Marshall, an outspoken social conservative who unsuccessfully sponsored a so-called bathroom bill in the state Legislature and refused to call Roem "she" or "her." Democrat Chris Hurst, a former local news anchor whose girlfriend and fellow reporter Alison Parker was murdered on live TV in 2015, also flipped a House seat from GOP control.

Other contests weren't as much of a surprise. In New Jersey, Democrat Phil Murphy easily bested Republican Lt. Gov. Kim Guadagno. Outgoing GOP Gov. Chris Christie has the lowest approval ratings of any governor in the country, and Trump remains deeply unpopular there as well. And in New York City, Democratic Mayor Bill de Blasio was easily re-elected to a second term.

It was the Virginia contests that were seen as the better bellwether ahead of 2018, when Democrats are hoping to make major gains as Trump's approval ratings continue to plummet. The last few weeks of the Virginia contest turned especially bitter as the race tightened. Gillespie doubled down on a Trumpian message, promising a crackdown on violence by Latino gangs and pledging to protect Confederate monuments. The messaging was a major turn for the former Republican National Committee chairman, but had he been successful it would have meant Republicans nationwide would not be afraid to embrace Trump's more populist, anti-establishment message come next year. Instead, Gillespie's hard right turn — after nearly losing the primary to a far-right challenger — didn't pay off in the general election.

Northam, meanwhile, tried to unite Democrats' centrist and progressive wings, although he upset the latter last week when he said he would be willing to sign a bill banning so-called sanctuary cities for undocumented immigrants. Those divides didn't appear to hurt him at the ballot box.

In his victory speech, Northam didn't mention Trump by name, but his message was clear — Virginia will be a welcoming place in comparison to Trump's immigration policies and broader nationalist agenda.

"We live in a very diverse society. It is getting more diverse every day. It is that diverse society that makes this country great," Northam said. "And as long as I'm governor I will make sure that we're inclusive, that we welcome people to the commonwealth of Virginia."

Copyright 2017 NPR. To see more, visit http://www.npr.org/.