RICHMOND, Va. — Voters in Virginia and New Jersey gave Democratic gubernatorial candidates large victories Tuesday and sent a clear message of rebuke to President Donald Trump.

In Virginia's hard-fought contest, Democratic Lt. Gov. Ralph Northam defeated Republican Ed Gillespie. In New Jersey front-running Democrat Phil Murphy overcame Republican Lt. Gov. Kim Guadagno to succeed unpopular GOP Gov. Chris Christie.

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.

Roseann Petropoulos said her opposition to Trump led her out in the cold rain to cast her ballot for Murphy in New Jersey.

"Trump was huge," she said. "Because back in the 70s when we got civil rights for people, women's rights, we have a chance for that to be reversed. It's scary."

Northam rode to victory in part by tapping into voters' regret at Trump's victory in last year's national election. Murphy had an easier pathway in New Jersey, where Guadagno contended with both Trump's and Christie's unpopularity.

Trump Tuesday night was distancing himself from Gillespie, Addressing the disappointing result in a race seen as an early referendum on his political clout, he wrote on Twitter that Gillespie "worked hard but did not embrace me or what I stand for."

The day earlier, he'd posted:

Gillespie largely tried to maintain his distance from Trump on the campaign trail.

Trump recorded robocalls to help boost Gillespie's candidacy on Election Day. In one call, Trump said Gillespie shared his views on immigration and crime and would help "Make America Great Again."

On what is shaping up to be a difficult night for Republicans, Trump is touting GOP victories earlier this year, writing, "With the economy doing record numbers, we will continue to win, even bigger than before!"

Northam, the state's lieutenant governor, repeatedly tried to tie Gillespie to the president. His victory was in large part due to a surge in anti-Trump energy 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 kept 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.

After Tuesday's loss though, 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, before pointing out that Republicans have won every special election to the U.S. House since he was elected.

In Virginia, Northam's victory is another sign of the state'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 antidote to Trump.

"We need comfort food, Ralph is comfort food," Del. John Bell told volunteer canvassers at a rally over the weekend.

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. 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. 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.

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.

Copyright 2017 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.

More From New Jersey 101.5 FM