ARLINGTON, Va. — Ed Gillespie, a former chairman of the Republican National Committee and a Washington lobbyist, barely claimed the Republican nomination for governor of Virginia on Tuesday, The Associated Press reported.

A top aide in President George W. Bush’s administration, Mr. Gillespie, 55, is very much a creature of the pre-Trump, establishment wing of his party. He will face a stiff test in the general election against the Democrat Ralph S. Northam, as he seeks to retain the support of conservatives who are enthusiastic backers of President Trump while not turning off the state’s often pivotal moderates, a decidedly anti-Trump voter bloc.

If at First You Don’t Succeed

This is Mr. Gillespie’s second bid for statewide office. In 2014, he ran unsuccessfully against Senator Mark Warner, a Democrat. It was not expected to be one of the marquee Senate races that year, but Mr. Gillespie gave Mr. Warner a scare, losing by less than a single point.

The Run-Up

The podcast that makes sense of the most delirious stretch of the 2016 campaign.

Running such an unexpectedly strong race gave Mr. Gillespie a leg up this year as a host of other high-profile Virginia Republicans deferred to him. If they had known how vulnerable he was on the right, some of those other would-be candidates may not have opted out of the race.

A Model for Success

A New Jersey-raised congressional aide-turned-Washington insider may not sound like the typical profile of a statewide candidate in a tradition-bound state like Virginia. But Mr. Gillespie has a model of sorts in the governor’s mansion today: Terry McAuliffe.

Mr. McAuliffe was raised in Syracuse before making a name for himself in national politics as the chairman of the Democratic National Committee. The governor and the would-be governor, who have a friendly relationship born of the greenroom circuit, have something else in common: Both came to the nation’s capital to attend college at the Catholic University of America.

Donald Who?

Mr. Gillespie, a firm devotee of Mr. Bush’s “compassionate conservatism,” is not generally fond of Mr. Trump’s hard-edge nationalism. In fact, it can be difficult to even hear him say the name of the president.

Mr. Gillespie often refers to supporting “the ticket” of his party in 2016, and he appears more comfortable around Vice President Mike Pence, a more conventional conservative. But given that Virginia is likely to be the most competitive race in the country this fall, Mr. Trump will probably take notice if Mr. Gillespie shuns him entirely during the campaign.

Connections Pay

Mr. Gillespie has already raised just shy of $5 million for the governor’s race and, with the help of the well-funded Republican Governors Association, he will not lack for financial resources this fall. He has a nationwide fund-raising network thanks to his time at the helm of the party in the Bush years, his Senate bid and his work with a group of third-party conservative organizations that have helped Republicans win congressional and statehouse races.

There are no limits on fund-raising in Virginia. Mr. Gillespie may be the best-connected Republican to seek the Virginia governorship in the state’s history.

Focused Like a Laser Beam on the Economy

Even as the two Democrats running for governor, Mr. Northam and Tom Perriello, veered to the left, Mr. Gillespie largely resisted targeting them on the sort of social issues that used to be staples of conservative attacks in Virginia. He has instead kept a focus on economic growth and cutting taxes, ignoring his Republican rivals.

This strategy imperiled him in his primary, but Mr. Gillespie feared getting pulled too far right and driving away more centrist general electorate voters. But Mr. Gillespie’s approach reveals the degree to which Virginia has shifted away from Republicans: His overarching message is indistinguishable from that of most mainstream Republican candidates running in blue states.