Virginia Gov. Terry McAuliffe (D) had tried to strike language explicitly requiring that the legislature approve any money used to expand Medicaid, but Republicans rebuffed that effort. (Steve Helber/AP)

The Virginia General Assembly completed work late Monday on a two-year, $96 billion state budget, averting a government shutdown and at least temporarily thwarting Gov. Terry McAuliffe’s key priority of expanding health coverage under the Affordable Care Act.

The setback for McAuliffe (D) — and the long-delayed finalization of the budget — came months into a bitter political standoff between the governor and legislative Republicans over whether to expand government-funded health coverage to 400,000 low-income Virginians under the controversial federal law. The issue has come to define McAuliffe’s young term as governor.

“It has been a very long session, and the good news is we have a budget,” said Del. S. Chris Jones (R-Suffolk), who has been a leader in the fight against Medicaid expansion as chairman of the House Appropriations Committee.

A key moment came Monday night when Virginia House Speaker William J. Howell (R-Stafford) tossed out a critical veto that the governor had hoped would make it easier to expand Medicaid without legislative approval. Three days after McAuliffe had declared that he would defy the legislature by seeking a way to expand the health-care program on his own, Howell outmaneuvered the governor with a procedural move that killed his line-item veto without a vote.

“I am continually surprised and disappointed by the lengths to which Republicans in the House of Delegates will go to prevent their own constituents from getting access to health care,” McAuliffe said in a written statement. “Instead of putting all of my vetoes through the process prescribed by the Constitution of Virginia, House Republicans robbed the voters of their voice by using a procedural gimmick to obstruct the normal legislative process where this veto was concerned.”

Del. Peter F. Farrell (R-Henrico) countered, “Speaker Howell calls them like he sees them.”

Legislators returned to Richmond on Monday to address several gubernatorial vetoes and to wrap up the long-overdue budget. After debate over some of McAuliffe’s amendments, Howell threw out two vetoes for procedural reasons. The House declined to act on five others, meaning they were sustained. It overrode the remaining one and sent it to the Senate, which sustained it. McAuliffe, who left for a trade mission to Southern California on Monday afternoon, had already signed the budget over the weekend after issuing his vetoes, so the budget was finalized once the legislative action on the vetoes was complete.

The budget keeps state spending at current levels in most cases — a much leaner spending plan than the House and Senate had envisioned earlier this year. Raises for teachers and state employees, inflation payments to hospitals, and K-12 spending boosts were scuttled late in the process because of a projected $1.5 billion revenue shortfall. Some areas did receive spending increases, including mental health.

Without a budget in place, the threat of a government shutdown put the state’s stellar bond rating at risk and also threatened to interrupt services to the state’s 8 million residents.

McAuliffe had tried to strike language explicitly requiring that the legislature approve any money used to expand Medicaid. Howell ruled that the veto was out of order because it attempted to veto a portion of a budget item, rather than an entire item. Howell said McAuliffe had made the veto “in a manner which I believe is outside his scope of authority.” By striking the veto on procedural grounds, Howell averted an override vote that would have required the support of two-thirds of both chambers — an unlikely outcome given the closely divided Senate.

Howell also ruled a second veto out of order. In that one, McAuliffe had sought to strike language preventing governors from appointing judges when the General Assembly is not in session. The legislature appoints judges, but until now the governor had authority to appoint some judges when it is not in session.

In addition to fiercely debating Medicaid expansion, delegates argued that democracy itself was at stake. “If you’re concerned about the separation of powers, listen to what he said Friday,” Del. Timothy D. Hugo (R-Fairfax) said, referring to McAuliffe’s declaration. “This is a dangerous precedent. This governor’s on the verge of setting a precedent that all of us here may well live to regret.”

House Minority Leader David J. Toscano (D-Charlottesville) urged Howell to let House members weigh in on the issues.

“Please do not use a parliamentary maneuver to deny everybody the right to vote,” Toscano said.

Of McAuliffe’s eight vetoes, the one related to Medicaid spending was considered most critical to McAuliffe’s go-it-alone expansion bid. Despite the setback, there is no question that McAuliffe will push ahead with his expansion plan. Less clear is how he can do so in a state where, even before the amendment, the constitution requires the legislature to sign off on any spending — even the pass-through spending that Washington has promised to bankroll most of Medicaid expansion.

Celebrated by Democrats but denounced as illegal by Republicans, McAuliffe’s plan to expand Medicaid unilaterally had the State Capitol in an intensely partisan mood even before the House and Senate gaveled in Monday.

While McAuliffe’s administration was moving ahead behind the scenes to explore expansion plans, House Republicans were researching parliamentary nitty-gritty to see whether they could block two vetoes that McAuliffe intended to ease expansion. Senate Republicans, meanwhile, were weighing whether the time would be right to take advantage of their new majority in the chamber and grab control of key committees.

Senate Republicans ultimately decided to seize the moment, shaking up committees that decide which bills make it to the floor for a vote and which ones die. Although Democrats reorganized the chamber to their liking when they last took power, they complained bitterly about the circumstance that allowed the GOP to take control: the sudden resignation of Sen. Phillip P. Puckett (D-Russell) two weeks ago. They have accused Republicans of bribing Puckett to step down in the middle of the budget standoff with promises of a top tobacco commission job for him and a judgeship for his daughter. Puckett has denied any quid pro quo but withdrew his name from consideration for the tobacco commission job. Federal investigators are looking into the matter.

Medicaid expansion was not formally on the agenda in the House or Senate. Worried about the shutdown threat, and given a final nudge by the surprise Senate resignation that tipped control of the chamber to the GOP, Democrats and three moderate Republicans caved two weeks ago in a months-long standoff, agreeing to a budget deal that did not include expansion.

The General Assembly has been locked all year in a battle over Medicaid expansion, McAuliffe’s marquee campaign issue. Senate supporters said it would help needy Virginians, create 30,000 jobs and buoy hospitals hit hard by cuts that the Medicaid funds were intended to offset under the Affordable Care Act.

GOP House leaders said the existing Medicaid program, which has ballooned to 22 percent of the overall state budget, needs more reform before it is expanded. Republicans have also questioned how an already overextended federal government can afford to keep its promise to pay most of the tab, about $2 billion a year in Virginia alone.

One of McAuliffe’s eight vetoes came over the weekend, related to whether certain budget-making documents have to be shared with the General Assembly. He announced the other seven Friday at a news conference, where he also declared that he would defy the legislature and find a way to expand Medicaid — and ordered his secretary of health and human resources, William A. Hazel Jr., to come up with a plan by Sept. 1.

Hazel and others in the administration were plowing ahead toward that goal Monday, though the governor’s office declined to say how they were going about that beyond meeting and evaluating options.

McAuliffe’s office did indicate, however, that more than just traditional Medicaid expansion was on the table. Hazel will be looking at ways to expand Medicaid but also other, unspecified options for providing health care.

Another of McAuliffe’s vetoes eliminated all language related to a state Medicaid commission.

The panel had been set up under then-Gov. Robert F. McDonnell (R) to determine whether the existing Medicaid program had achieved certain goals that the legislature required before expansion could take place. Democrats had pushed for its creation, but Republicans had used it to thwart expansion.

McAuliffe called the commission a “sham to pretend that the legislature is serious about Medicaid reform and expansion.” His veto was seen as largely symbolic because language creating the commission will remain in the state code even if it is removed from the budget.

Another veto strips $300,000 in funding for an ethics commission created in response to a $165,000 gifts scandal involving McDonnell and his wife, Maureen. McAuliffe signed the bill creating the commission and made no substantive changes to ethics legislation the legislature passed this year. But on Friday, he took a harder line, saying that legislators should be subjected to tougher rules and that funding the commission should wait until those are passed. On Monday, the House overrode McAuliffe’s veto of the ethics bill, but the Senate did not muster the votes to follow suit, so McAuliffe’s veto was sustained.

McAuliffe also issued a directive that state staffers suspend all planning work for a $300 million Capitol Square office building meant to house lawmakers and their staffs. McAuliffe had previously signed off on the building.