Ed Gillespie, the Republican candidate for governor of Virginia. (Steve Helber/AP)

IF ED GILLESPIE wrote a memoir about his current campaign as Virginia's Republican gubernatorial candidate, he might call it "The Art of the Tightrope."

Caught between the right-wingers, nationalists and racists who form the core of President Trump's support and the hard fact that Virginia hasn't elected a Republican to statewide office since 2009, Mr. Gillespie is treading the narrowest of political paths. A longtime Republican insider and former consigliere to George W. Bush, he is a moderate by disposition. But giving voice to that moderation risks alienating the Trump coalition. In the spring's GOP primary, he narrowly avoided defeat at the hands of Prince William Board of County Supervisors Chairman Corey A. Stewart, a Trump fan.

That has left Mr. Gillespie in an awkward position in his race for governor against the Democratic nominee, Lt. Gov. Ralph Northam. He endorsed Mr. Trump during last year's campaign but ever since has studiously avoided nearly any mention of the president's name. He has called for criminal-justice reforms that would keep many small-time offenders from prison, but he ducked the tougher question of restoring felons' voting rights by proposing a commission to be named later.

Mr. Gillespie said localities should decide what to do about Confederate monuments, then shifted almost immediately to adamantly oppose their removal. He declined to join in the divisive dog whistling so relished by Mr. Trump, then hired Mr. Trump's own field director for Southwest Virginia, Jack Morgan, a blowhard who says America is headed for a civil war and that the movement to take down Confederate monuments is a communist plot to subvert the nation.

Mr. Gillespie isn't the first politician to walk a political tightrope while trying not to alienate ideologically divergent factions of his party and the broader electorate. Yet the question arises: Does he have any core principles?

Many who have known him for years regard Mr. Gillespie as a centrist and a pragmatist — in other words, an establishment Republican of the sort loathed by the party's ascendant Trump loyalists. Yet by hiring a provocateur such as Mr. Morgan and using Confederate monuments as a wedge issue, he may be solidifying the GOP base while at the same time courting white nationalists already energized by Mr. Trump's race-baiting.

There is a moral cost to winking at the most noxious elements in the electorate; there may also be a political cost, especially in Virginia. Increasingly dominated by the cosmopolitan suburban precincts of Northern Virginia, the state's electorate has not rewarded candidates who have flirted with extremists. Mr. Gillespie might bear that in mind as he zigzags his way across the commonwealth.