Columnist

President Trump may have been 7,000 miles away in Seoul on Tuesday, but make no mistake: He was on the ballot in Virginia when his imitator, Republican Ed Gillespie, lost the closely watched gubernatorial race to Democrat Ralph Northam.

This was, in part, because Trump himself embraced Gillespie, endorsing him and, as Election Day arrived, tweeting about the "terrible" Virginia economy, its "high crime" and its gangs, and urging support for Gillespie.

But more than that, Trump was on the ballot because Gillespie, in the general election, attempted to remake himself as a Trump clone. He played down conventional Republican talk about tax cuts in favor of a racially charged campaign right from the Trump playbook: support for Confederate monuments, fear of immigrants and outrageous calumny about Northam being a friend of pedophiles.

The commonwealth on Tuesday night gave a resounding rejection to this filth. With 98 percent of precincts reporting, Northam had won by more than eight percentage points.

The half of voters who said in exit polls that Trump was a factor opposed the president by 2 to 1. Among the half who said that Trump wasn't a factor — they favored Gillespie by 15 points — well, perhaps it was more that they wished Trump weren't a factor in the race.

Though polls had showed a tightening race (which many attributed to Gillespie's embrace of Trump-style cultural warfare), Northam's margin of victory was greater than Hillary Clinton's over Trump in this swing state. And Northam, it must be said, was not exactly an electrifying candidate; he ran a campaign that often seemed hesitant and confused.

1 of 41 Full Screen Autoplay Close Skip Ad × The scene during the Virginia elections View Photos Voters in Virginia elected Democrat Ralph Northam over Republican Ed Gillespie as the next governor. Caption Voters in Virginia elected Democrat Ralph Northam over Republican Ed Gillespie as the next governor. Astrid Riecken/For The Washington Post Buy Photo Wait 1 second to continue.

Essentially, Gillespie turned the Virginia gubernatorial race into a cultural war, much as Trump did with the 2016 election. But this time, the cultural warrior lost, as he sorely deserved to.

The ads were disgraceful: Gillespie's "Kill, Rape, Control" ad falsely warning that "Northam cast the deciding vote in favor of sanctuary cities" and, therefore, the MS-13 gang. The reckless ads casting Northam as protector of "sex offenders" and "convicted sexual predator[s]." And Gillespie's ad about Confederate statues: "I'm for keeping 'em up, and he's for taking 'em down."

Views on race were perhaps the clearest predictor of how Virginians voted. Ninety-seven percent of those who trusted Northam more on race, exit polls showed, supported him. For Gillespie the number was 98 percent. Gillespie did have a 44-point advantage among the 57 percent of Virginians who want Confederate monuments to stay — but Northam had a whopping 83-point advantage among the 38 percent who want them down. Four in 10 Virginians named health care — the issue at the center of Northam's candidacy — as their top issue, while only 1 in 8 named immigration, which Gillespie tried to make front and center.

Democrats will rightly celebrate Northam's win, but that comes with a depressing asterisk. Gillespie's campaign shows even more clearly than the Trump victory did that, among Trump (and Gillespie) supporters, racial animus and cultural grievances are a greater factor than conventional issues such as economic well-being.

After Trump's win in 2016, many Trump-friendly analysts ridiculed the establishment elites, in the Washington swamp, for failing to appreciate the economic troubles in rural, Middle America that Trump recognized. But national study after study since then has reached similar conclusions: Economic factors were secondary to cultural factors among Trump supporters, particularly hostility to immigrants and racial and religious minorities.

In Virginia, there was a pure test of this. Its 3.7 percent unemployment rate is among the lowest in the country, and a large majority of Virginians say the local economy is good. And Gillespie is the very epitome of the Washington swamp: party boss, K Street lobbyist, Capitol Hill and White House staffer. He was even once a Senate parking-lot attendant.

What was left to Gillespie, then, were mostly the cultural issues — and Trump voters embraced him anyway. Among the 40 percent in exit polls who approved of Trump's job performance, fully 91 percent voted for Gillespie. There weren't enough Trump voters for Gillespie to win, but there were a lot — and there will be enough to allow some Republicans who run similar campaigns to win elsewhere next year.

Gillespie may have been doomed even if he remained the mainstream Republican candidate he was when he barely survived the primary against a Trump-inspired gadfly, when he properly denounced white supremacists in August, or when he set out to run a campaign about the economy and taxes. We'll never know.

But we do know that Trump was 180 degrees off when he sent this defensive tweet Tuesday night after Gillespie lost: "Ed Gillespie worked hard but did not embrace me or what I stand for."

No, Mr. President. The problem was precisely Gillespie's embrace of you.

Read more from Dana Milbank's archive, follow him on Twitter or subscribe to his updates on Facebook.