FALLS CHURCH, Va. — The bloody white supremacist rally in Charlottesville, Va., has thrust race and history to the forefront of this year’s campaign for governor in Virginia, a tradition-bound state whose identity has always been rooted in a past that is as proud for some residents as it is painful for others.

The gubernatorial race in this swing state was already set to be the next big test of the nation’s politics, its results inevitably to be read as a harbinger for the 2018 midterm elections and President Trump’s fate. But the events last weekend in one of its historical centers — in the city that Thomas Jefferson called home and on the university campus that he designed and founded — ensure that the nation’s highest-profile campaign this fall will also be fought in part along the highly combustible lines of racial politics.

With Mr. Trump defending Confederate statues and his former top strategist, Stephen K. Bannon, openly inviting Democrats to continue focusing on the issue of removing monuments, the president will loom large over the commonwealth in November.

It is a course that leaves both parties somewhat discomfited, both because of Virginia’s bifurcated demography and the cautious nature of the two candidates.