The Virginia General Assembly adopted a long-delayed state budget late Thursday, acting after an hours-long debate among newly ascendant Senate Republicans who fought among themselves over whether the plan threw up sufficient barriers to Medicaid expansion.

The Republicans, who gained control of the Senate Monday when a Democrat resigned from what had been an evenly split chamber, approved a spending deal hashed out by a bipartisan group of House and Senate negotiators.

But they first amended it in a way intended to make it harder to expand the federal-state healthcare program for the poor under the federal Affordable Care Act — Gov. Terry McAuliffe’s top legislative priority.

As midnight approached, the plan moved over for consideration by the House of Delegates, where it quickly passed. It was expected to then head to McAuliffe’s desk, but with no certainty that he would approve it and avert a government shutdown before July 1.

McAuliffe quickly issued a statement after the House vote: “When this budget reaches my desk I will evaluate it carefully and take the actions that I deem necessary, but this fight is far from over. This is the right thing to do for Virginia, and I will not rest until we get it done.”

The Senate vote came after Republicans huddled behind closed doors and argued — at times yelling, two participants said — over whether they should tinker with the budget deal and risk undermining it.

Some were incensed that legislators had returned to the Capitol from the farthest reaches of the commonwealth, expecting to pass a spending plan in time to avert a July 1 government shutdown, only to risk sinking the deal by amending it.

Sen. Richard H. Black (R-Loudoun) wanted to introduce a floor amendment intended to prevent McAuliffe (D) — or an independent Medicaid commission — from expanding Medicaid without the General Assembly’s explicit approval. Black’s caucus eventually settled on an alternative that eliminates the wording Black had been concerned with and would require that the General Assembly authorize any increased spending on Medicaid.

Either way, Democrats said the amendments would kill any chance of Medicaid expansion for the next two years. “It was nonsense,” Sen. Chap Petersen said. “We are actually increasing taxes on our citizens by rejecting $2 billion in federal money. Stupidest thing I ever heard of.”

Countered Black: “This was a stunning victory for the Republicans. We passed a budget in a single night and we have effectively blocked Medicaid expansion.”

A single Democrat, Lynwood Lewis, voted for the budget.

Senate Republicans found themselves divided over Black’s amendment just three days after they gained control of the chamber, and two days after House Majority Leader Eric Cantor (R-Va.) suffered a stunning primary loss to Dave Brat, an underfunded, little-known candidate backed by the tea party.

The discontent that felled Cantor loomed over the GOP meeting, with some explicitly invoking the loss as a caution against passing anything that might be construed as supporting the Affordable Care Act, said one senator, who spoke on the condition of anonymity in order to discuss private caucus matters.

News of the GOP discord leaked out via Twitter even as the party’s Senate caucus was privately fighting it out. A tweet from Sen. Tom Garrett (R-Louisa) said, “#blackorbust I WON’T vote for a budget that lacks #dickblack amendment,” and “The full GA should vote up or down on #medicaidexpansion. No tricks.”

Black’s push came after expansion opponents have argued for months that Medicaid expansion and the budget should be considered separately.

McAuliffe, who made Medicaid expansion the centerpiece of his campaign last fall, vowed during the race and at some points as governor that he would not sign a budget that did not provide health insurance to 400,000 uninsured Virginians.

His office has not indicated whether he would go along with the current budget plan, which House and Senate budget negotiators started hashing out behind the scenes a few weeks ago after new state revenue forecasts projected a $1.5 billion shortfall over the two-year budget period.

“Obviously, he wants Medicaid in there — he thinks it’s the right thing for Virginia. But right now, it’s the General Assembly’s responsibility to send him a budget, and the governor will review it carefully,” McAuliffe spokesman Brian Coy said earlier in the week. “We will make announcements about whatever actions he takes when the review is complete.”

Black raised concerns the previous day about language in the budget that he feared would allow McAuliffe to expand Medicaid administration. The language states: “There is hereby appropriated sum sufficient nongeneral funds for such costs as may be incurred to implement coverage for newly eligible individuals pursuant to . . . the Patient Protection and Affordable Care Act.”

Matthew Moran, a spokesman for House Speaker William J. Howell (R-Stafford), has said the language would not give a governor authority to expand Medicaid on his own. He said it was carried over from the previous budget. Its purpose is to authorize additional Medicaid spending if — and only if — a state Medicaid commission set up by the legislature agrees to expansion, he said.

The budget plan calls for holding most state spending at current levels to account for a projected budget shortfall. The rival budget plans produced by the House and Senate during the regular General Assembly session were both more flush, with extra money for state employee pay raises, universities, hospitals and K-12 education.

But those plans died when legislators failed to strike a budget deal before the regular session concluded March 8. McAuliffe, Senate Democrats and three moderate Republicans in that chamber support expanding health-care coverage to as many as 400,000 uninsured Virginians. The GOP-dominated House is firmly opposed, questioning whether Washington can afford to keep its promise to pick up most of the $2 billion-a-year tab.

State budget officials said the cause of the shortfall was primarily a miscalculation of capital gains tax revenue; forecasters misinterpreted a one-time spike, triggered by an anticipated change in federal tax policy, as a long-term rise that they could count on in the current budget and beyond.

The projected shortfall added urgency to the long-stalled negotiations. So did the fast-approaching July 1 deadline.

The breakthrough came Monday, when a Democratic senator stepped down, suddenly giving Republicans a 20-to-19 edge in the chamber.

The three moderate Senate Republicans continue to support a form of Medicaid expansion. Even with the departure of Sen. Phillip P. Puckett (D-Russell), expansion supporters still outnumber opponents in that chamber 22 to 17.

But with the House showing no signs of budging and a potential shutdown looming, they have agreed that the budget must come first. Senate Finance Committee Chairman Charles J. Colgan (D-Prince William), has also indicated that he thinks the state needs to get a budget in place first.

It remains to be seen how McAuliffe will react to the budget. Once it reaches his desk, he will have seven days to make changes and send the bill back to the legislature.