Mr. Gillespie, who just a decade ago warned his party against the “siren song” of weaponizing immigration, has poured millions into racially tinged television ads and mailings that excoriate Mr. Northam on that issue, as well as Confederate monuments, the restoration of felons’ rights and even football players who kneel during the national anthem.
This onslaught over issues of culture and identity, a mix of the Trumpian tactics of today with the unvarnished appeals from the past in a state defined by race since Jamestown, has appalled Democrats in Virginia and beyond.
The gut-punch approach has left even some Republicans wincing over the spectacle of a former Republican National Committee chairman and New Jersey native trying to win with earnest vows to guard emblems of the Lost Cause and with warnings about menacing Hispanic gangs.
Yet Mr. Gillespie’s strategy has brought him within a few points of Mr. Northam in both public and private polling. A New York Times Upshot/Siena College poll, released on Sunday, showed Mr. Northam with just a three-point lead over Mr. Gillespie, 43 percent to 40 percent.
That has forced nervous Democrats to confront the reality that race, immigration and crime can be a potent mix even in a rapidly suburbanizing state where Hillary Clinton won by more than five points last year and where, overall, the president remains deeply unpopular.
“I don’t think it will work in Virginia, but I just don’t know,” said Representative Robert C. Scott, Virginia’s first black congressman since Reconstruction.
Should Mr. Gillespie win or narrowly fall short, he will have handed 2018 candidates in competitive races a playbook for Trump-era campaigns: deploy the president’s politics but avoid Mr. Trump himself.
Democratic officials have been especially troubled as their ostensible allies have responded with ham-handed scare tactics of their own and demanded that their candidates reject any policies that carry even the whiff of Trumpism.
In an attempt to stir nonwhite voters, and draw attention from the news media and would-be donors, a liberal Hispanic advocacy group released an ad last week depicting a man in a pickup bearing a Gillespie sticker speeding after panicked children of color. The group, the Latino Victory Fund, pulled the commercial down after the deadly truck attack in New York, but not before offering Republicans a rallying cry to motivate their base and forcing Mr. Northam to distance himself from the spot.
At a get-out-the-vote rally Saturday for Mr. Gillespie and the Republican ticket in Fairfax County, a suburb of Washington that is Virginia’s most populous locality, speaker after speaker inveighed against the racially motivated ad, while avoiding any mention of their own standard-bearer’s appeals.
Credit Nikki Fox/The Daily News-Record, via Associated Press
“It is the most disgusting thing I’ve ever seen in politics,” said Gov. Larry Hogan of Maryland, a fellow Republican who ventured across the Potomac for Mr. Gillespie.
While the displays of umbrage illustrated how desperate Republicans are to seize any opening, the dust-up illustrated the determination of some liberals to fight fire with fire, even if it creates a mess for their nominee.
“Will Rogers was never proven wrong,” said Mr. Scott, invoking Rogers’s oft-cited aphorism that, as a Democrat, he belonged to no organized party.
Also worrisome to Democratic strategists was how some elements of the left reacted when Mr. Northam indicated in an interview last week that he would sign a law banning sanctuary cities, localities that offer a blanket of protection from federal immigration authorities. One liberal group, Democracy for America, withdrew its support from Mr. Northam, and a founder of the “resistance” organization Indivisible implored the nominee, who is under fire from Mr. Gillespie for opposing a state measure that would have banned sanctuary cities, to “find your spine.”
The fratricide illustrated how, as Democrats become more organized around their own identity politics, it is growing ever more difficult for their candidates to stray from the liberal line on any issue that veers toward race.
And it was the second time Mr. Northam, a moderate by inclination, equivocated on a racially charged issue in an effort to satisfy liberals and more centrist voters: Earlier in the campaign he said he would lead the effort to take down Confederate statues, only to subsequently say he would defer to local authorities.
In an interview here on Saturday after he stopped at a bustling Asian food hall that featured Hawaiian-style poke bowls, Vietnamese coffee ice cream in ash coconut waffle cones and an ethnic fusion of voters to match, Mr. Northam demonstrated how tricky immigration politics is becoming for his party.
Asked whether those found to be in the country illegally should be deported at all, he repeated the question and then declined to say.
“That’s a federal issue,” said Mr. Northam, a former Army doctor who voted for George W. Bush twice before entering politics, adding that he would “support local law enforcement.”
Veteran Democrats hear such equivocation and see peril ahead.
“If the debate is set up so that Republicans are the only ones who want some sort of order or limitations on immigration and Democrats want zero, we will lose that debate every single day,” said Kenneth Baer, a Democratic strategist. “We need to say that immigration makes the country strong and is at the core of who we are, and this is how we do it: with order, laws and compassion. Unfortunately, Trump is boxing us into being the open borders party, which is not where most of the country is.”
It is unclear how much leeway on immigration the Democratic base will give its office holders. Mr. Northam’s most rousing applause lines have come when he has said that Virginia is a welcoming and inclusive state, whether it was when former President Barack Obama appeared in Richmond for a rally last month or when Mr. Northam addressed a group of Arlington County Democrats last week.
What ultimately may save Mr. Northam on Tuesday, though, was captured by another speaker in Arlington, among the most liberal jurisdictions in the state. “I don’t know about you, but the funk that I have been in since Nov. 8 of last year, it still hasn’t worn off,” said Christian Dorsey, a member of the County Board.
Virginia Democrats, especially in the Washington suburbs, view this election as an exercise in cathartic revenge against Mr. Trump. “Democrats want to send a message,” said Thomas M. Davis III, a former Republican congressman from Virginia.
Mr. Gillespie is conscious of giving Democrats the chance to link him directly to Mr. Trump. At the sparsely attended Republican rally in Fairfax County on Saturday, not one speaker mentioned the president’s name. Nor did Mr. Gillespie say a word about the core of his advertising campaign, ignoring the MS-13 gang, felons’ rights and Confederate statues.
Afterward, George Allen, the former Republican governor and senator, noted that Mr. Trump was “off in Asia now.” Indeed, the only hint of the president came via a 20-foot, golden-maned inflatable chicken that Democrats had set up across the street to taunt Mr. Gillespie about his refusal to be seen with Mr. Trump.
But a table filled with the stickers and literature of Republican candidates offered a stark reminder of how Mr. Trump’s adopted party is embracing his politics: A door hanger ready for distribution presented a blurry picture of Mr. Northam and criticized him for backing a state proposal in favor of sanctuary cities, restoring rights to criminals and supporting “taxpayer-funded benefits for illegal immigrants.”