"The days of division are over. We will move forward," Murphy said in his victory speech.

The wins in Virginia and New Jersey are a morale boost to Democrats who had so far been unable to channel anti-Trump energy into success at the ballot box in a major election this year.

"The people are gonna rise up. They're not gonna take what he says and this is not fake news," said Leanna Barnes, a 76-year-old from East Orange, New Jersey, who voted for Murphy and added she saw his victory as a message to the president.

Virginia college student Tamia Mallory said she began paying attention to her state's gubernatorial race when she saw tweets from Trump endorsing Gillespie. That motivated her to examine the race and find out who was running against Gillespie, she said.

"It was kind of an anti-Trump vote," Mallory said.

Northam, the state's lieutenant governor, repeatedly sought during long months of divisive campaigning to tie Gillespie to the president. His victory was in large part due to the surge in anti-Trump sentiment since the president took office. Democrats said they had record levels of enthusiasm heading into the race in Virginia, a swing-state and the only Southern state that Trump lost last year.

Gillespie, meanwhile, sought to keep Trump at a distance throughout the campaign but tried to rally the president's supporters with hard-edge attack ads focused on illegal immigration and preserving Confederate statues. The strategy was criticized by Democrats and some Republicans as race baiting, but drew praise from former Trump strategist Steve Bannon and others as a canny way to win a state that voted for Hillary Clinton last year.

Trump lent limited pre-election support to Gillespie with robocalls and tweets.

In one call, Trump said Gillespie shared his views on immigration and crime and would help "Make America Great Again." Trump also said Northam would be a "total disaster" for Virginia.

But after Tuesday's loss, Trump suggested that Gillespie hurt himself by not more closely aligning himself with the president.

"Ed Gillespie worked hard but did not embrace me or what I stand for," Trump said in a tweet after Northam won. He also pointed out that Republicans have won every special election to the U.S. House since he was elected.

Northam's victory is a blow to Republicans, who were hoping that Gillespie could provide a possible roadmap for moderate Republicans to follow in next year's midterm elections. Several Republicans have announced plans to retire next year instead of seeking re-election.

Gillespie struck a humble tone in his concession speech as he offered support to Northam.

He wiped tears from his eyes while thanking his wife and said the million people who voted for him love Virginia, and so do those who disagree with them.

"And I know they too are rooting for our new governor to succeed because we all love the commonwealth of Virginia," Gillespie said.

The mood was subdued at Gillespie's party at a Richmond-area hotel, with supporters not shocked at the outcome but surprised at how poorly Republicans did. Democrats swept all three of Virginia's statewide races, including contests for attorney general and lieutenant governor. Several incumbent state House Republicans also lost their seats.

Gillespie supporter Elsa Smith said Republicans needed to do a better job of appealing to minorities if they want to win future races.

"We are not taking care of the demographics the way we should," said Smith, an owner of a Spanish translation business.

Democrats were gleeful at Northam's victory party. U.S. Rep. Gerry Connolly called Northam the "perfect antidote" to the president.

"This is a comprehensive victory from the statehouse to the courthouse. Thank you, President Trump," Connolly said.

The Democratic victories are another sign of Virginia's shift toward a more liberal electorate. Democrats have won every statewide election since 2009 and now have won four out of the last five gubernatorial contests. Northam banked heavily during the campaign on his near-perfect political resume and tried to cast himself as the low-key doctor with a strong Southern drawl as the healer to Trump's divisiveness.

A pediatric neurologist and Army doctor, Northam made health care reform a centerpiece of his political career and current campaign, winning key allies along the way. As a state senator he was a leading opponent of a Republican effort to mandate ultrasounds before abortions in 2012, winning him strong support from well-funded abortion-rights groups.