Former Virginia attorney general Jerry Kilgore was among those who favored picking 2017 nominees via primary. (Bob Brown/AP)

Virginia Republicans will pick their 2017 nominees for governor and other statewide offices in a primary instead of a convention, the party decided Saturday in an about-face that infuriated some grass-roots activists and could have an impact on the presidential election.

The decision was made in a 41-to-40 vote after a passionate, hour-long debate and a surprise appearance by vice-presidential contender Mike Pence, who stressed the critical role Virginia will play in November’s election but did not weigh in on the convention-vs.-primary question.

The switch to the primary embittered some grass-roots activists because the party had recommended making its 2017 picks by convention — a format that tends to favor conservative candidates — just over a year ago.

Some warned the reversal would demoralize activists ahead of the presidential contest. But others said the move would prompt them to seek revenge on the establishment wing by turning out in droves for Donald Trump.

“This is a complete betrayal of the grass roots,” Waverly Woods, a GOP activist from Virginia Beach, fumed after the vote. “This party now — it’s imploding on itself because these Republicans can’t keep their word. . . . I hope everybody now jumps on the Trump train.”

State-run primaries are held in polling places across the commonwealth and are open to all voters because there is no party registration in Virginia. Conventions are day-long events that tend to attract only the most committed — and conservative — activists.

In a compromise in June 2015, the party agreed to choose its 2016 presidential nominee in a primary and made a recommendation for a convention in 2017, when the party will pick its nominee for governor, lieutenant governor, attorney general and possibly U.S. Senate, if Democrat Hillary Clinton wins the presidency and Sen. Tim Kaine (D-Va.) becomes vice president.

[Va. GOP will choose presidential nominee by primary]

But by the narrowest of margins Saturday, members of the State Central Committee gathering in Richmond voted to change course.

The party has changed its mind on the nomination method before, including in 2012, when forces loyal to gubernatorial contender Ken Cuccinelli II scuttled a planned 2013 gubernatorial primary for a convention. Many in the establishment wing of the party blamed that process for nominating candidates Democrats successfully painted as too conservative for Virginia’s changing electorate.

Saturday’s change to the nomination plan came as the party is trying to rebound from a string of losses — and as Virginia is poised to play a key role in choosing the next president. That message was reinforced by Pence’s appearance, which was sandwiched between a meeting with the Richmond Times-Dispatch’s editorial board and a rally in Northern Virginia.

“The road to the White House runs straight through Virginia,” Pence said.

Republicans at the Richmond Convention Center seemed genuinely excited to see Pence — notable because the state’s delegation to the Republican National Convention had supported one of Trump’s rivals, Sen. Ted Cruz of Texas, by a wide margin.

But the party’s divisions were soon on display, with advocates for conventions and primaries squaring off over which method could best reverse the fortunes of a party that has not won a statewide election since 2009.

Activists took turns making their pitches, often with passion but usually with decorum. Shouting broke out only once, as the sides disagreed over whether military personnel deployed overseas are able to participate in conventions.

Those who favor primaries said it would help the party reach more voters, including students, single parents, small-business owners and others who find it hard to travel across the state to a convention.

“We are not less Republican because we’re choosing to study,” said Ben Dessart, 25, a University of Richmond law student who warned that with conventions, the party would be “silencing the next generation of Republicans.”

Those who favor conventions said they forced candidates to engage in retail politics around the state, instead of running via TV ads and sound bites. They also said the event serves as an important fundraiser for the party.

Dan Webb, who proposed the compromise plan last year, said the party will be bitterly divided if it is seen as reneging on what he called a “gentlemen’s agreement.”

“We have been internally wracked with divisions,” he said. “We have an opportunity to show goodwill. . . . I’m really tired of losing.”

National Committeman Morton Blackwell also warned that Democrats eager to meddle would vote in the primary — particularly in a year when Democrats have already lined up behind their nominees for two offices: Lt. Gov. Ralph Northam for governor, and the incumbent attorney general, Mark R. Herring.

“We will have large numbers of hostile Democrats participating,” he said. “We shouldn’t let it happen.”

But former attorney general Jerry Kilgore, who backed Sen. Marco Rubio of Florida for the presidential nomination, said Republicans will pull together to support Trump and the party’s 2017 nominees.

“We’re not going to be divided,” he said. “My nominee didn’t win the presidential nomination this year, but I’m here, and I’m supporting our nominee.”