RICHMOND — When nearly two dozen Republican legislators voted last year to expand Medicaid in Virginia — a stunning flip on a marquee pledge to resist “Obamacare” — outraged conservatives vowed to oust them in party primaries.

The conservative powerhouse Americans for Prosperity targeted them with radio and Facebook ads, organized “Stop Obamacare” meetings across the state and warned through a spokesman, “Politicians usually pay a price when they ignore their constituents.”

But when the state holds its primary on Tuesday, only three Republicans who supported Medicaid expansion will face challengers. A pair of delegates and one state senator find themselves in nomination battles, two of which will be decided June 11. The nomination method is a matter of dispute in the third contest.

The popularity of Medicaid expansion — which has provided government health insurance to an additional 280,000 low-
income Virginians since Jan. 1 — could account for the small number of primaries, said Del. Terry G. Kilgore (R-Scott), who represents Southwest Virginia and voted for expansion.

“I think it’s helping a lot of people, especially down my way,” he said. “I think that people saw there was a need, and they saw there was all this federal money that other states were getting. And I think that’s where it landed.”

There may be other reasons most Republicans who voted to expand Medicaid escaped primaries. Some say potential challengers were wary of going to war with fellow Republicans at a time when the party is trying to hang on to razor-thin majorities in the House and Senate. And then there are the long odds of defeating an incumbent, even one who has broken with party orthodoxy.

In 2004, 34 Republican legislators voted for a $1.4 billion-a-year tax hike favored by then-Gov. Mark R. Warner (D). Americans for Tax Reform put their images on a Wild West-style “Least Wanted” poster.

“A posse of taxpayers may send them away,” it said.

In the end, just four drew primary challengers. One was defeated. That was Del. Gary Reese, a Fairfax Republican who on different occasions voted for and against the tax increase, which funded schools and public safety.

“I think the lesson that was learned from that was, it might be harder than it seems to knock off a Republican incumbent in a primary like that over an issue that a lot of voters are going to benefit from,” said Quentin Kidd, a Christopher Newport University political scientist and dean of the school’s Wason Center for Public Policy.

In 2013, 34 House Republicans supported a transportation funding overhaul backed by then-Gov. Robert F. McDonnell (R) that imposed $1.2 billion a year in new taxes. Four were primaried, and two — Del. Joe T. May (Loudoun) and Del. Beverly J. Sherwood (Frederick) — lost.

Under the Affordable Care Act championed by President Barack Obama, Washington allows states to open their Medicaid rolls to people with incomes up to 138 percent of the federal poverty level, which is $16,643 for an individual. The federal government pledged to pay at least 90 percent of the cost, which in Virginia would amount to about $2 billion a year.

Democrats said expansion would help the poor and boost the economy by creating thousands of new health-care jobs. But the Republican-controlled legislature refused it for years, saying they feared the federal government would renege on its funding promise and leave Virginia with an unbearable tab.

Opposition in the House crumbled after Democrats nearly won control of the chamber in November 2017, amid a blue wave widely viewed as a rebuke of President Trump. GOP House leaders tried to smooth the way with messaging, billing expansion as conservative “Medicaid reform” since the plan included work requirements for recipients. That requirement, which critics on the right dismissed as a nonbinding “work suggestion,” awaits a sign-off from the Trump administration.

That February, 19 of the 51 House Republicans joined Democrats to pass a budget bill that expanded Medicaid, apparently concluding that they had more to fear from energized Democrats and independents than from potential primary challengers on the right.

The Senate did not get on board until May, when four Republicans broke ranks. That makes 23 pro-expansion Republicans between the two chambers. Four are retiring. Of the remaining 19 seeking reelection, only Sen. Emmett W. Hanger Jr. (Augusta), Del. Christopher K. Peace (Hanover) and Del. Robert M. Thomas Jr. (Stafford) have GOP challengers.

In all three contests, Medicaid is just one of several issues at play.

Hanger is a folksy veteran legislator with a maverick streak who has been primaried before. Though he is a social conservative, he tends to favor more funding for education and safety-net services than the majority of his caucus.

He has represented the mostly rural 24th district, which stretches from Culpeper to the Shenandoah Valley, since 1996. He served in the House from 1983 to 1992.

His challenger is Tina Freitas, a political blogger and community volunteer who is married to Del. Nicholas J. Freitas (R-Culpeper). She has gone after Hanger with sharp-edged videos with the theme, “Top 10 reasons why Emmett Hanger needs to hang it up.”

Medicaid is just one of her beefs. Freitas has said Hanger is not conservative enough on abortion and guns. It is a line of attack that Hanger has not faced before; he has an A rating from the National Rifle Association and regularly earns 0 percent ratings from NARAL Pro-Choice Virginia.

Hanger has raised $319,613 to Freitas’s $72,588, according to the nonprofit Virginia Public Access Project.

Thomas is a freshman delegate representing the 28th District, which covers Stafford County and Fredericksburg. He ran in 2017 on a promise to oppose Medicaid expansion but voted for it three months later. The flip earned him a rematch with former Stafford supervisor Paul ­Milde, who sought the nomination two years ago.

Milde goes after Thomas on Facebook for “Expansion of the Socialist Obamacare Medicaid scheme.” The challenger also suggests that the incumbent is soft on abortion and guns. Thomas has an A rating from the NRA and is the father of eight children. Thomas countered the abortion claim by saying that he would support a law similar to one passed recently in Georgia, which would outlaw abortions after a doctor can detect a fetal heartbeat but includes exceptions for incest, rape and situations of medical futility or where the health of the mother is at stake.

Thomas has only a small financial edge, raising $232,375 to Milde’s $203,686.

For 13 years, Peace has represented the 97th District, suburban-rural territory northeast of Richmond that includes Hanover, King William and New Kent counties.

Peace’s support for expansion drew special ire because in a tweet, he compared opposition to Medicaid expansion to “Massive Resistance,” Virginia’s campaign to obstruct integration of public schools in the 1950s. Hanover County Supervisor Scott Wyatt jumped in to challenge him.

Their contest has been a strange one, focused primarily on the method of nomination — a convention versus a “firehouse primary.” Conventions — day-long events at a single location, sometimes with multiple rounds of balloting — tend to attract only the most dedicated activists and therefore tend to favor more conservative candidates. The firehouse primary is quicker and more convenient, with polling places in each county and paper ballots that voters fill out and leave behind.

Wyatt, who has raised $44,839, wanted a convention, and he says he got one on May 4 and prevailed. Peace and the state GOP say that gathering was not a sanctioned convention, although several Senate Republicans, including Majority Leader Thomas K. Norment Jr. (James City), have waded in on Wyatt’s side.

Peace, who has raised $237,522, favored a firehouse primary, which he won on Saturday.

The dispute is likely to wind up before party committees and perhaps court.