Ralph Northam’s election as Virginia governor amid reportedly high turnout on Tuesday is a stinging and welcome rebuke to President Trump and white nationalism.

Mr. Northam’s Republican rival, Ed Gillespie, an establishment operative, chose to dog-whistle himself breathless in pursuit of the state’s pro-Trump white voters, and the president attested to his make-America-great-again credentials. By late Tuesday, though, Mr. Trump was trying to sidle away from Mr. Gillespie, claiming that a candidate who sacrificed his own reputation to adopt the president’s style and positions in fact “did not embrace me or what I stand for.” Mr. Gillespie did, and he lost.

Virginia and New Jersey, where Democrat Phil Murphy easily won the governor’s race, were the first statewide general elections since Donald Trump won the presidency a year ago, and Virginia, the only southern state Hillary Clinton won in 2016, was by far the more consequential of the two. Late Tuesday Democrats were also registering gains in the Virginia House of Delegates, suggesting strong disapproval of Mr. Trump at the grass roots.

Having been nearly vanquished in the primary by Corey Stewart, an anti-immigrant conspiracy theorist who played on issues like preserving Confederate monuments, Mr. Gillespie, at the advice of Republican leaders, took up race-baiting. His ads, featuring menacing tattooed men, accused Mr. Northam of being “weak on MS-13,” the gang formed by Central American immigrants in Los Angeles that now threatens Virginia suburbs. They contained some of the darkest appeals in Tuesday’s off-year contests — and that’s saying something, given the Republican candidate ads that aired in places like Nassau County, N.Y., and New Jersey.