After what had already been a torturous day of arm twisting and vote-counting, top lieutenants in the Maryland House of Delegates thought they had nailed down just enough support Tuesday to pass Gov. Martin O’Malley’s expanded gambling plan.

Then, about 8 p.m., came word that two delegates — both of whom pledged to vote for the bill — were gone.

One, a woman in her 80s, was headed home to Baltimore because she wasn’t feeling well. The other, who is undergoing chemotherapy, was rumored to have left the State House and headed to the hospital.

“All of a sudden, on a very close vote, you’re down two votes,” said House Speaker Michael E. Busch (D-Anne Arundel).

The bill, which calls for a statewide vote on whether to allow the new Prince George’s County casino as well as table games at Maryland’s other authorized slots sites, passed shortly before midnight with 71 votes — the bare number needed.

About a half-hour later, the Senate — a chamber far more friendly to gambling legislation — signed off on House changes and sent the legislation to O’Malley (D), who had been unusually hands-on in recent days pushing for its passage.

O’Malley signed the bill Wednesday morning in a relaxed fashion that belied the whirlwind of the previous 24 hours, during which House leaders cajoled members, traded favors and sought to balance the desires of lawmakers from jurisdictions with competing interests.

“It was like a game of pick-up sticks,” said Del. Justin D. Ross (D-Prince George’s), the House’s No. 2 vote counter. “You have to be careful if you move one, the rest don’t come crashing down.”

While the stakes were high for gaming companies that operate in Maryland, there was a lot riding on the outcome for both O’Malley and Busch, too.

A similar bill collapsed on the final night of this year’s regular session. Now lawmakers were back in Annapolis, in a special session called by O’Malley, to try again. A similar outcome would have proven a major embarrassment for both men.

Busch, who has presided over the House for a decade, longer than any other speaker in Maryland history, had pulled out tough votes before. In February, a same-sex marriage bill cleared the House with just one vote to spare.

“I knew it would be a struggle to get there, but I was confident we would get there in the end,” Busch said Wednesday.

They weren’t quite there when the day began.

Busch pulled his Democratic delegates together shortly after 11 a.m. for a closed-door caucus, during which members were walked through a PowerPoint presentation. For many, it was the first time they saw details of the bill as amended Monday by a House committee.

A headline in the local Annapolis paper, the Capital, was already causing consternation: “Maryland Live! wins big under House bill.”

That referred to additional concessions the House committee granted to the state’s largest casino, as well as to one planned in Baltimore, for the new competition that would come with a Prince George’s gambling venue. All told, the two other casinos would get to keep roughly $30 million more a year in revenue than under a bill passed by the Senate.

Some delegates said they weren’t sure they could stomach giving such a big break to rich casino owners. But Busch had pushed for the change on the grounds that any expansion bill had to be fair to current casino owners.

During the caucus, another issue of fairness arose: A Democratic delegate from Cecil County complained that, under existing law, some revenue generated by a casino in his county was flowing to Baltimore to aid neighborhoods around Pimlico Race Course. A compromise was reached hours later.

The episode was recounted Wednesday in a “legislative diary” e-mailed by Del. Samuel I. Rosenberg (D-Baltimore) to supporters. The headline on this installment: “Slots and Sausage.”

The sausage-making would continue well into the evening. It was clear that the votes of few delegates remained in play — but there were many who wanted something to shore up their support.

The House was scheduled to begin debate on the bill at 2 p.m. It would not start until about 4:30 p.m.

In between, as gaming company lobbyists milled about outside the chamber, a stream of delegates visited Busch in his office to talk about possible amendments.

That included a measure to significantly expand the number of veterans organizations allowed to have up to five lottery devices that are similar in appearance to slot machines.

The provision, which had long been a priority for VFW halls and American Legion posts, had little to do with the underlying bill. But it was a way, House leaders acknowledged, to bolster support for the measure among the more-conservative Democrats in the chamber who might otherwise have had no compelling reason to vote for it.

A letter in support of the provision sent by the American Legion was circulating among House members by the time the amendment was debated.

“This is something to help build them back up again,” Del. Joseph J. “Sonny” Minnick (D-Baltimore County) argued to his colleagues.

House Minority Leader Anthony J. O’Donnell (R-Calvert) countered that veterans were being “used” to leverage votes.

Tuesday presented other challenges for O’Donnell. The Republican caucus he leads announced before the session that it was opposed to O’Malley’s bill.

On Tuesday, however, O’Malley and House leaders were able to lure five of the chamber’s 43 Republicans to their side. Without them, the bill would have failed.

Two were brought on board Tuesday night with an amendment that affects a planned casino at Rocky Gap Lodge & Golf Resort in their part of the state. Rather than build a separate casino, the recently licensed operator there is planning to install slot machines in a conference center that is already part of the property.

The amendment is meant to ensure that the operator will replace the conference space more quickly.

One of the missing “yes” votes was eventually located. Del. Veronica L. Turner, who many had thought had been taken to the hospital, was actually resting nearby.

“I knew we were short, so I stayed,” said Turner (D-Prince George’s). “I wanted to make sure I was there when they needed my vote.”