RICHMOND — Attorney General Ken Cuccinelli II is questioning the legality of a budget deal that provided a framework for Medicaid expansion, a position that now threatens to scuttle an $880-million-a-year transportation package and throw the final day of the General Assembly session into disarray.

House and Senate budget negotiators had reached a compromise that would make it easier to expand Medicaid if certain reforms were implemented. Democrats had insisted on the language, saying they would oppose the transportation-funding overhaul if they did not get a written promise from Gov. Robert F. McDonnell (R) agreeing to the broad outlines of the Medicaid compromise.

McDonnell produced his letter Friday night, a few hours after the General Assembly had adjourned for the day. That appeared to clear the way for legislators to wrap up work on the budget and transportation funding by Saturday, the last day of session.

But the legal opinion by Cuccinelli, the presumptive Republican nominee in this year’s governor’s race, has thrown that agreement into doubt.

“It is my opinion that the General Assembly may not delegate final legislative authority regarding budget or other matters to a committee composed of a subset of members of the General Assembly,” Cuccinelli wrote.

The Medicaid deal called for allowing a panel with 10 legislators to authorize expansion of the federal health-care program for the poor, elderly and disabled if certain reforms were implemented as part of the federal Affordable Care Act. It was a compromise between a House bill, which would have required the entire General Assembly to approve expansion, and a Senate bill, would would have allowed the state health officials to do so.

Del. Ben Cline, co-chairman of the conservative caucus, had sought the legal opinion from Cuccinelli. Cline (R-Rockbridge) opposed both the transportation bill and Medicaid expansion.

Democrats conceded privately on Saturday that the opinion by Cuccinelli, who sued the federal government over the Affordable Care Act, is probably correct.

McDonnell spokesman Tucker Martin said Saturday that the governor’s office is reviewing the opinion.

“Medicaid and transportation are not connected, and are two completely different policy issues. . . .Yesterday, the transportation bill passed the House with strong bipartisan support,” Martin said via e-mail. “This is the closest we’ve been to passing a long-term transportation funding plan for Virginians in 27 years. It is time to act to improve transportation in Virginia, and this is that opportunity. We urge the Senate to vote on the transportation bill today.”

As a purely procedural matter, Cuccinelli’s legal opinion need not stop the General Assembly from passing either legislation. The chambers could send the budget bill back to a conference committee, which could strip out the offending language and return it to the floor.

But politically, the opinion could torpedoed both bills. Democrats may be unwilling to approve a transportation measure without assurances on Medicaid expansion. It was unclear if they would be willing to give up their leverage by voting on transportation without a deal on Medicaid. And Republicans, already wary of the transportation deal, could withdraw their support if another deal is worked out to smooth the way for Medicaid expansion.