US Democrat Ralph Northam has defeated Republican Ed Gillespie in the race for the governorship of Virginia, marking his party’s first major Trump-era victory.

The results in the state were replicated in several contests across America on Tuesday as the Trump resistance struck back at the US president’s nationalist rhetoric.

Mr Northam, a paediatric neurologist and Army veteran, led Mr Gillespie by several points as the final votes ticked in.

Democrats also scored victories in the gubernatorial race for New Jersey and in Maine, where voters slapped the state’s Republican governor, a Trump ally, by backing a measure to expand Medicaid coverage under former president Barack Obama’s flagship health care law.

The Democratic mayors of New York and Boston, both vocal Trump critics, also won re-election easily.

Virginia voters also elected the state’s first openly-transgender state representative, among more than a dozen state legislative gains for Democrats.

Danica RoemDanica Roem, centre, a former journalist, is set to make history as the first openly transgender person elected and seated in a state legislature in the United States (Jahi Chikwendiu/The Washington Post via AP)

The resounding victories marked the Republicans’ most significant day of defeat in Donald Trump’s presidency, as well as a rebuke to the leader himself as his party eyes a suddenly more threatening mid-term election season next year.

Democratic National Committee Chairman Tom Perez said: “The Democratic Party is back, my friends.”

As Democrats celebrated, Republicans pointed fingers. The president himself tweeted: “Ed Gillespie worked hard but did not embrace me or what I stand for.”

Mr Trump did note that his party won a handful of special elections earlier in the year, adding: “With the economy doing record numbers, we will continue to win, even bigger than before!”

Despite the criticism, Mr Gillespie did, in many ways, embrace what Mr Trump stands for, even if he did not welcome the president into the state to rally voters on his behalf.

Mr Trump played a marginal role in Virginia, largely because Republicans on the ground did not want him there, a state he lost last autumn, as his approval ratings hover near record lows.

US governors(PA Graphics)

The White House instead dispatched Vice President Mike Pence to help Mr Gillespie, although Mr Trump promised Gillespie would “make America great again” in a recorded phone message that went to voters on the election’s final day.

Mr Gillespie, a former aide to ex-president George W Bush and Republican presidential candidate Mitt Romney, largely reinvented himself as election day neared by adopting many of Mr Trump’s racially-tinged nationalist positions.

He warned of the dangers of the Hispanic street gang, MS-13, and highlighted its motto, “Kill, Rape, Control”, in a television ad. The New Jersey native also vowed to protect Confederate monuments, and condemned the national anthem protests by NFL players.

Ed GillespieRepublican candidate for Virginia governor Ed Gillespie shakes hands with supporters before voting at his polling place in Alexandria (Alex Brandon/AP)

In the days before the election, former Trump chief strategist Steve Bannon said Mr Gillespie’s embrace of “Trumpism” offered a roadmap for other Republican candidates nationwide heading into the 2018 mid-term elections. Mr Bannon did not respond to a request for comment late on Tuesday.

In New Jersey, Democrat Phil Murphy trounced Republican Lt Gov Kim Guadagno, who served under the term-limited, deeply unpopular Republican governor Chris Christie.

New Jersey Democratic senator Cory Booker, who is one of several Democrats weighing up a possible presidential bid in 2020, cast his party’s gubernatorial victories in New Jersey and Virginia as “the very first state-wide rebuttal of the Trump administration”.

US elections(PA Graphics)

And he declared: “We will not succumb to the politics of fear.”

The day also exposed deepening regional divisions between America’s two major political parties.

Democrats picked up one state Senate seat in Washington state, which flipped control of the state legislature from Republicans to Democrats.

In so doing, Democrats now control every governor’s office and state legislature on the West Coast.

While Democrats also control a cluster of state governments in the North-east, Republicans, however, control state legislatures across the entire South, all but one state in the Midwest and the vast majority of the mountain West.

Excited Democrats hope to flip control of several state houses next year just as state leaders prepare for the once-in-a-decade task of resetting congressional boundaries, a process known as redistricting.