UPDATE — Tuesday, 11/7/2017, 9:30 p.m. Democrat Ralph Northam has won the race for Virginia governor, beating Republican Ed Gillespie in the hard-fought race.

The race for governor in Virginia wasn’t supposed to be particularly competitive. Depending on which polls you believe, maybe it won’t be. There is nevertheless a certain amount of suspense as voters head to the polls on Tuesday.

Republican Ed Gillespie looked like he would be particularly hard hit by President Trump. Trump is bitterly unpopular in Northern Virginia’s populous D.C. suburbs, where past GOP standard-bearers have been wiped out. Yet Trump performed strongly in the southwestern part of the commonwealth last year, where conservative voters often want stronger stuff than Gillespie’s technocratic center-right platform.

The first time this race took an unexpected turn was during the June primaries. Gillespie was expected to win the Republican gubernatorial nomination easily, while Democratic Lt. Gov. Ralph Northam was in a dogfight with the Bernie Sanders-backed former Congressman Tom Perriello.

Instead Northam won the Democratic nomination by a comfortable margin while Gillespie barely eked out a victory over Prince William County Board of Supervisors Chairman Corey Stewart, a former state chairman for Trump who proved too Trumpy even for the president’s campaign.

That suggested Gillespie would find it difficult to simultaneously keep Trump at arm’s length to stem the bleeding in Northern Virginia and also turn out the Republican base in parts of the state where the president is still popular, while the Sanders versus Hillary Clinton divide would have little relevance to the general election.

This conventional wisdom is about to be severely tested. The polls have varied in the final weeks of the campaign, with a 17-point Northam lead at one extreme and an 8-point Gillespie advantage at the other. But the recent trend has suggested the race tightening, mostly in Gillespie’s favor. The RealClearPolitics average shows Northam clinging to a 1.8-point lead.

Gillespie has kept Trump at a safe distance, leaving the president to tout his candidacy on Twitter while former President Barack Obama stumps with Northam. Yet the usually conventional Bush Republican has run a far more Trump-like campaign than anyone anticipated.

The former Republican National Committee chairman has taken a surprisingly hard line against illegal immigration, opposing sanctuary cities that make enforcement so difficult. He has promised to crack down on the MS-13. And Gillespie has spoken in favor of keeping up Confederate statues that dot the Virginia landscape.

This, along with a campaign ad hitting Northam and incumbent Democratic Gov. Terry McAuliffe for the restoration of a convicted sex offender’s voting rights, earned Gillespie a rebuke from the Washington Post editorial board.

“Once known as a pragmatist and a centrist, Mr. Gillespie increasingly has been turning in his political advertising to President Trump’s brand of divisive, scaremongering politics,” the Post editorialized. “It’s a poisonous strategy for the nation and for Virginia.”

But is it a winning strategy? Another “poisonous” ad that has played an important role in the Virginia gubernatorial campaign is a spot by the Latino Victory Fund, which showed a truck with both a Gillespie bumper sticker and a Confederate flag chasing and apparently trying to run down minority children. It was pulled after an Uzbek immigrant claiming an affinity for ISIS terrorists actually did run down people in New York City.

The ad was produced by an outside group, not Northam’s own campaign. But the Democrat did have to report it as an in-kind contribution. And it was a logical outgrowth of Democratic statements that Gillespie is running a racist (or at least race-baiting) campaign.

Like Hillary Clinton’s attacks on “deplorables” during last year’s presidential race, many right-leaning voters are likely to see the ad as an attack on themselves. Republicans haven’t been shy about drawing attention to it. Prior to the ad, Northam had faced criticism from Democrats as to whether he was doing enough to encourage minority turnout.

The recent trend in Virginia has been for Republicans to exceed expectations but comes up just short, such as when Ken Cuccinelli narrowly lost the governorship to McAuliffe four years ago or when Gillespie came within a percentage point of popular Democratic Sen. Mark Warner in 2014.

If Gillespie wins in this increasingly purple state, it will scramble a lot of assumptions people are making about the 2018 midterm elections a year out. If he loses narrowly, the meaning will be hotly debated. And if he is defeated by a wide margin, the headline will surely be that once-respectable Republicans are riding Trumpism into a ditch.

In the meantime, this contest almost looks like a replay of Trump vs. Clinton. We’ll see if the results are any different.

W. James Antle III is politics editor of the Washington Examiner and author of Devouring Freedom: Can Big Government Ever Be Stopped?