Senate Minority Leader Richard L. Saslaw (D-Fairfax), left, Sen. Emmett W. Hanger, Jr. (R-Augusta) and Senate Majority Leader Thomas K. Norment Jr. (R-James City) have a spirited discussion during the floor session of the Virginia Senate as it met to deal with the state budget at the State Capitol on May 22, 2018. (Bob Brown/AP)

The Virginia legislature voted Wednesday to make government health insurance available to 400,000 low-income residents, overcoming five years of GOP resistance. The decision marks a leftward shift in the legislature and an enormous win for Gov. Ralph Northam (D), the pediatrician who ran on expanding access to health care.

Virginia will join 32 other states and the District in expanding Medicaid coverage. The measure is expected to take effect Jan. 1.

“This is not just about helping this group of people,” said Sen. Frank Wagner (Virginia Beach), one of four Republicans in the Senate who split from their party to join Democrats and pass the measure by a vote of 23 to 17. “This is about getting out there and helping to bend the cost of health care for every Virginian. . . . It is the number one issue on our voters’ minds. By golly, it ought to be the number one issue on the General Assembly’s mind.”

Another Republican who broke ranks, Sen. Ben Chafin (Russell), is a lawyer and a cattle farmer from a rural district where health care is sorely lacking.

“I came to the conclusion that ‘no’ just wasn’t the answer anymore, that doing nothing about the medical conditions, the state of health care in my district, just wasn’t the answer any longer,” he said.

After the Senate vote, the House of Delegates approved the measure by 67 to 31 as the chamber erupted in cheers.

“This budget is the culmination of five years of effort to bring our taxpayer dollars home from Washington and expand Medicaid,” said Northam, who is expected to sign the bill. “As a doctor, I’m so proud of the significant step we’ve taken together to help Virginians get quality, affordable care.”

Terry White of Chesapeake greeted the news with “Thank you, Jesus!” White, 50, lost private insurance when severe arthritis forced him to give up work in the Newport News shipyards in 2008. He uses a walker, has congestive heart failure and has been treated for prostate cancer, but he is ineligible for Medicaid under the current system. He has racked up enormous medical bills and had to move in with a sister. “That’s a blessing. That’s gonna help a lot of people.”

The increasing political power of the state’s wealthy suburbs, which have helped Democrats win every statewide office since 2009, nudged the legislature toward expansion, said Stephen Farnsworth, a political scientist at the University of Mary Washington.

“The fortunes for the Republican Party in Richmond were not good if the party stood mainly for divisive issues like no Medicaid expansion, no abortion and no restrictions on guns,” he said. “That’s a losing trifecta in suburban Virginia, and that’s where the votes are.”

Despite Republican efforts to tear it down, the Affordable Care Act “has become more popular than it ever was, and the opportunity to balance the state’s budget with an influx of federal funds became an increasingly popular choice,” he said.

Under the act, 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.

The Republican-controlled state legislature refused it for years. GOP leaders said they feared the federal government would renege on its funding promise, sticking Virginia with an unbearable tab.

“If I spent money like the federal government, then I’d be sleeping in my car and somebody’d be trying to repossess the car,” said Sen. Richard Black (R-Loudoun).

But opposition in the House crumbled after Democrats nearly won control of the chamber in November, amid a blue wave widely viewed as a rebuke to President Trump. A chastened House Speaker M. Kirkland Cox (R-Colonial Heights), seeking to rebrand Republicans as results-oriented pragmatists, came out in favor of expansion if work requirements, co-pays and other conservative strings were attached.

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

Easing their evolution was Northam’s assumption of the governorship in January. The former state senator and lieutenant governor, a soft-spoken pediatrician and former Army doctor once wooed by Republicans, has close friends on both sides of the aisle. His predecessor, Terry McAuliffe (D), tried to expand Medicaid for four years but did not enjoy the same respect and trust from Republicans in Richmond.

In an odd twist, it was the Virginia Senate — traditionally the more moderate chamber and the one that had backed expansion in previous years with help from two now-retired moderate Republicans — that had remained dug in.

That split between the House and the Senate forced the legislature to adjourn its regular session March 10 without a budget. Legislators must pass a spending plan by July 1 to avoid a shutdown of the state government.

Virginia’s existing Medicaid program is one of the least generous in the nation. To be eligible, a disabled individual can make no more than $9,700 a year. The cutoff for a family of three is $6,900. Able-bodied, childless adults are not eligible, no matter how poor.

Under the Affordable Care Act, Virginia can raise those income limits to $16,750 a year for a disabled person or able-bodied adult, and $28,700 for a family of three.

The leanness — some say stinginess — of the current Medicaid program partly accounts for Virginia’s reluctance to expand. The current program covers 1 million, so adding 400,000 represents a 40 percent increase — a much bigger leap for Virginia than for most other states.

Republican holdouts in the Senate saw the carnage last year when Democrats flipped 15 House seats, but they were insulated because they were not on the ballot. And some doubted that embracing “Obamacare” would help their party, which has not won a statewide election since 2009. While voters called health care a priority in exit polls, some Senate Republicans blamed the GOP losses in November on an anti-Trump wave, not pro-Medicaid fervor.

They fought up to the moment of the vote Wednesday, with 10 hours of procedural moves, passionate floor speeches and an appearance by former U.S. senator Rick Santorum (R-Pa.), who left office in 2007 and ran unsuccessfully for the presidency in 2012 and 2016. He warned senators that Obamacare could be killed by Congress.

“We are picking up some momentum. I feel very, very good” that legislation repealing the ACA will advance in Congress, said Santorum, who now lives in Virginia. “That means that everything that happened here will be for naught; in fact, you’ll create something that you’ll have to get rid of in a matter of two years.”

Santorum’s appearance was organized by Americans for Prosperity, a conservative activist group funded by the Koch brothers. People wearing green Americans for Prosperity shirts and holding signs calling for “No Medicaid expansion in Virginia” lined the meeting room. Expansion supporters waited in the hallway outside; their signs reminded individual senators of the percentage of voters in their districts who favor expansion.

Capitol Police had to separate the two factions when they got into a shouting match, a rarity in the marble corridors where a staffer regularly scolds anyone who speaks above a whisper.

Senate Majority Leader Thomas K. Norment Jr. (R) slammed the vote, saying that it “abandons Virginia’s long-standing reputation for fiscal responsibility.”

In a floor speech, he also lamented the tone of the debate.

“In the years I have been in the Senate, I have never been treated more disrespectfully by some of these advocacy groups,” he said. “Lying down in front of my office . . . with made-up tombstones, asking people to blow their horns when they go past my law office. . . . The verbal abuse I took yesterday, just walking from the Pocahantas Building, was unbelievable.”

In the end, Wagner and Chafin joined two other Republicans, Emmett W. Hanger Jr. (Augusta) and Sen. Jill Holtzman Vogel (R-Fauquier), to vote for expansion.