RICHMOND — Deep inside the nitty-gritty of Virginia’s transportation overhaul lies a little legislative jujitsu.

When Gov. Robert F. McDonnell (R) proposed a bill to raise $845 million a year for roads, transit and rail, he bet on federal legislation allowing states to collect tax on Internet sales to deliver $250 million a year of that. Democrats ridiculed that provision on grounds that McDonnell could not count on that money since the Marketplace Equity Act had long been stalled in Congress.

By the time the General Assembly passed its much-amended version of McDonnell’s transportation overhaul Saturday, it included a contingency: If the federal legislation does not pass by January 2015, retail taxes on gas would rise 1.7 percentage points to make up for the lost revenue.

But there was another, little-noticed sweetener for Democrats — one that bets against passage of the Marketplace Equity Act as heavily as McDonnell bet on it.

Under a provision wrangled out of fellow transportation conferees by Sen. Janet D. Howell (D-Fairfax), the amount of general fund revenue directed to transportation would fall from nearly $200 million a year to $60 million a year if the Marketplace Equity Act doesn’t pass.

Democrats have long opposed paying for transportation from that fund, which bankrolls services such as schools, health care and public safety.

Howell and other Democrats were celebrating that victory Saturday, along with their ability to get language inserted into the budget intended to make it easier to expand Medicaid if certain conditions are met.

Democrats had threatened to hold up passage of the transportation deal, which McDonnell very much wanted, if he did not provide a written pledge that he agreed with the broad outlines of the Medicaid language.

McDonnell provided the statement, though his office insisted that the two issues were never linked.

At a news conference right after adjournment, Howell said the Senate Democrats had stuck together to shape the outcome of “two of the most important policies implemented in Virginia in decades.”

Republicans, however, suggested that the Medicaid language included in a package of budget amendments could actually make it harder to expand the program.

Earlier in the week, House and Senate budget negotiators had reached a deal on Medicaid. It called for allowing a commission with 10 legislators — five from the House, five from the Senate — to authorize expansion of the federal health-care program for the poor, elderly and disabled if Washington allowed Virginia to reform the way the program is run in the state.

It was a compromise between the House position, which would have required the entire General Assembly to approve expansion, and the Senate’s, which would have allowed state health officials to do so. That appeared to smooth the way for passage of the budget amendments and transportation on Saturday, the last day of session. But early Saturday, a legal opinion from Attorney General Ken Cuccinelli II (R) began circulating, saying the commission was unconstitutional.

“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.

After Cuccinelli warned that the Medicaid language was unconstitutional, budget conferees huddled with lawyers to rework it and then push it through both chambers.

Under the amended budget language, the legislature still appoints a commission with 10 legislators to oversee implementation of any Medicaid reform and expansion. But rather than empower the commission to expand Medicaid on its own, the General Assembly preemptively directs the commission to do so if certain reforms are implemented. Commission members will merely decide if the reforms have been accomplished, triggering expansion if and when they do so.

The language aimed to get around Cuccinelli’s objection that the legislature cannot delegate its budget authority to a smaller subset of the assembly. The amended budget directly appropriated any necessary funds for implementing the expansion, contingent on implementation of the reforms, so the commission would not be empowered to do so.

McDonnell said the Medicaid provision, which puts expansion at the discretion of the panel of 10 legislators, will “set a clear firewall against expansion.”

His reasoning is that it could be harder to get the commission to agree that Medicaid has been sufficiently reformed — particularly since the agreement specifies that a simple majority vote of the panel would not be enough to vote for expansion. At least three members from each chamber would have to agree that reform has been completed.

A simple majority of the panel might be more inclined to move ahead with expansion because the five commission members from the more moderate Senate would only need to convince one House member to join them. It is expected to be a tougher sell to convince three members of the more conservative House to go along.

Before Saturday’s budget vote, Republican leadership assured House members in a closed-door caucus meeting that they would appoint members to the commission who will take a very strict view of what constitutes reform, according to one GOP delegate and a Capitol staffer briefed on the plan.

“The caucus was given assurance that these would be people who would hold the line on Medicaid expansion,” said the delegate, who spoke on condition of anonymity in order to discuss private caucus matters. “This notion that we made it easier to expand Medicare is wrong. I think it’s the opposite.”

The delegate noted that without the budget language, Medicaid expansion was at the discretion of the governor. With a governor’s race this year and the possibility that a Democrat could win, the change in the rules could work against expansion.

“It takes the control away from the governor — where Terry McAuliffe could be the next governor — and puts the control in a body where House Republicans have the last say,” said the staffer, referring to the former Democratic National Committee chairman running for governor against Cuccinelli.