ALEXANDRIA, Va. — For Ed Gillespie, Trumpism was an ill-fitting suit.
His résumé was pure establishment — national #Republican Party chairman, counselor to President George W. Bush, well-connected K Street lobbyist. But the messaging of his campaign for governor of Virginia was that of a cultural flamethrower, emphasizing crimes by undocumented immigrants as well as monuments to Confederate heroes — and even suggesting that his opponent, a pediatric neurologist, supported child pornographers.
As the Republican candidate, Mr. Gillespie tried to run in a very narrow lane by embracing some of the most divisive elements of President Trump’s agenda while treating him like Voldemort and mostly refusing to utter his name. It was enough to motivate Mr. Trump’s supporters in rural parts of the state, but fell far short in Northern Virginia, where the wealthy and well-educated voters who were once reliably Republican continued their march toward becoming solidly Democratic.
Lessons from off-year elections can be overdrawn, but the Virginia race strongly suggests that Republicans running in swing states will have to choose a side rather than try to straddle an uncomfortable line. Mr. Trump’s blunt force, all-or-nothing approach has worked in deeply conservative areas, but Republicans will have trouble replicating that in certain states in the midterms next year when faced with a diverse, highly educated electorate like the one in Virginia.
“We now know what a lot of us in the party already knew: The Trump message is a big loser in swing states and he hurts the G.O.P. far more than helps in those states,” Mike Murphy, a Republican strategist and critic of the president, said in an email. “Suburban voters don’t like Trump and his antics energize Democrats. The myth of Trump electoral power will now start to melt. A wildly unpopular president is a big political problem for the G.O.P. in swing states.”
Another prominent Republican aligned with conservatives called the results, including a number of legislative races, a “clear repudiation” of the party.
The outcome also showed that women were highly motivated to vote for the Democratic nominee, Lt. Gov. Ralph S. Northam, and other Democrats, including several female candidates running in Northern Virginia who defeated incumbent Republicans in state General Assembly races. The prominence of female candidates and the energy behind them here is something that the party will try to repeat in other states.
“I usually resist the temptation to nationalize these races in Virginia, but Trump has been an overbearing presence in this election, and Ed Gillespie chose to run a campaign modeled after the kind of campaign Trump ran last year,” said Mark J. Rozell, dean of the Schar School of Policy and Government at George Mason University. “This was the first big test in the Trump era of the appeal of Trump-style politics at the state level. The president injected himself in this campaign, so he owns some of it.”
Indeed, the president suggested that Mr. Gillespie’s biggest problem was not embracing him enough. “Ed Gillespie worked hard but did not embrace me or what I stand for,” Mr. Trump said on Twitter Tuesday night.