The Democratic Party's ongoing bitter strife over the 2016 campaign is casting an ominous shadow over its most important electoral test since Donald Trump won the presidency: Virginia's off-year race for governor.

For months, Ralph Northam, the state's lieutenant governor, had been the favorite in the commonwealth contest to succeed fellow Democrat Terry McAuliffe. But Republicans are increasingly sanguine about Ed Gillespie's chances of pulling off a come-from-behind upset Tuesday that would toss Democrats into a state of panic and set off another round of recriminations and infighting.

"As he showed in 2014, Gillespie is a very strong finisher," says Alex Conant, a GOP consultant whose firm has polled the contest, referencing Gillespie's past challenge to Sen. Mark Warner, of Virginia. "The last two weeks have been the best of the campaign for him, so he's peaking at the right time. Meanwhile, the Democrats seem hopelessly divided and unenthused about the race."

The final days of the contest have played out amid a nasty clash between former Democratic National Committee interim chair Donna Brazile and operatives of Hillary Clinton's presidential campaign, after Brazile accused Clinton of forging an unfair agreement with the DNC during last year's primary that boiled down to Clinton and Sen. Bernie Sanders.

At the same time, some ostensible allies have expressed their dismay with Northam's progressive credentials, as well as his failure to inspire. As a liberal panel discussed Northam's shortcomings during a forum at the Center for American Progress last week, a woman in the audience shouted, "He was a terrible candidate!"

"He's just less exciting is the main thing," said Ruy Teixeira, a political scientist and senior fellow at CAP.

Democracy for America, a progressive outfit launched by former Vermont Gov. Howard Dean, abruptly announced its withdrawal of support for Northam after he said he would sign a bill to ban so-called sanctuary cities, which provide shielding from federal immigration law. Dean responded , calling his former group's decision "destructive and foolish."

Northam also suffered blowback from an incendiary television advertisement by the Latino Victory Fund that showed a truck with a Confederate flag and a Gillespie sticker chasing minority children through a neighborhood. Northam has tried to distance himself from the ad, though financial disclosure documents show his campaign has received thousands of dollars in in-kind contributions described as "media" and "advertising" from the Latino Victory PAC. The spot was pulled last week after a short run and in the wake of the Oct. 31 New York terror attack involving a truck.

For his part, after adeptly steering clear of Trump and his controversies for most of the campaign, Gillespie adopted some of the president's scorched-earth, culturally tinged messaging in the homestretch, airing ads warning of the danger of MS-13 gangs and embracing the preservation of Confederate monuments. Though Trump never visited Virginia on Gillespie's behalf, he has tweeted his support for the GOP standard-bearer and his former chief strategist, Steve Bannon, told a gathering Saturday he believed Gillespie would pull out a victory on the backs of Trump voters.

Still, surveys have shown Northam with a small advantage in the first statewide general election of Trump's tenure. The RealClearPolitics' polling average heading into Election Day places Northam's lead at 3.3 percentage points, still well within the margin of error of most polls. McAuliffe won his race in 2013 by 2.5 points.

Clinton defeated Trump in the state by roughly 5 points a year ago and Republicans haven't won a statewide election in Virginia since 2009, when Bob McDonnell captured the governorship.

Both parties are now bracing for a razor-thin finish, which is why many leading Democrats were so unnerved by the timing of the Brazile bombshell and how it reopened wounds when the party needed to be most unified.

Some Democrats are already speaking as if Northam has lost the contest and are posing questions about the lessons the party will need to heed.

"If he does not win ... did we lose on the crime issue? Did we lose on the public safety issue?" former Tennessee Rep. Harold Ford Jr. said Monday morning on MSNBC. A Washington Post poll found Gillespie with an 8-point advantage on crime and a 3-point advantage on immigration, while holding only a 1-point lead on taxes – an indication that his cultural messaging was more potent and popular.

Inevitably, a Northam loss would rip open a fresh debate – not unlike the one Democrats are still having regarding the Clinton-Sanders primary – about whether a more staunchly progressive or rhetorically aggressive candidate would have fared better. While during the primary against former Rep. Tom Perriello, Northam ran an ad calling Trump a "narcissistic maniac," he put up a spot in the general election saying he'd work with the president on shared areas of interest.

"After the 2017 election, there will be a moment of introspection for the Democratic Party as it decides what direction to take in advance of 2018 and 2020," said Stephanie Taylor, co-founder of the Progressive Change Campaign Committee. "Does it field milquetoast, establishment candidates and Blue Dogs that run as Republicans – or does it field inspiring, authentic candidates who run on bold, popular, economic populist ideas?"

Perhaps more consequential for Democrats is that a Gillespie victory would validate a GOP strategy that played on racial and anti-immigrant emotions and could be replicated in the 2018 congressional midterms. Trump, too, would be emboldened, despite his peripheral role, and could tout a fifth electoral win this year, including victories in four special House races.

Some Democrats have urged party stalwarts to halt the fighting in order to pull Northam over the finish line.

"Enough," Ron Klain , former chief of staff to Vice President Joe Biden, said Saturday. "Any Democrat not focused on Northam vs. Gillespie is not focused [on] what really matters."

Tom Perez, the current DNC chair who's battling questions about his own leadership, spent the weekend in Virginia campaigning for Northam, while Perriello has been a consistent advocate on the trail for his former rival.

Klain says he is expecting a close finish, but one that will place Northam on top. "I think Democrats are uniting behind Northam and pushing everything else aside," he says.

But if Democrats fall short, at least they'll have New Jersey's gubernatorial contest to point to.