Whatever ills Maryland’s gambling program might breed among its residents, the past week made this much clear: The issue remains toxic in Annapolis.

The messy end to Maryland’s 90-day legislative session exposed a long-festering rift between the two veteran leaders of the General Assembly — and highlighted Gov. Martin O’Malley’s inability to reprise his peacemaker role.

House Speaker Michael E. Busch (D-Anne Arundel) and Senate President Thomas V. Mike Miller Jr. (D-Calvert) can probably agree on this much: A late-moving gambling bill led to the legislature’s failure Monday night to pass a tax package both chambers had negotiated.

That failure will trigger more than $500 million in cuts to education and other planned spending on July 1 if lawmakers don’t return before then for a special session, a prospect that led to days of posturing by Busch, Miller and O’Malley (D).

Gambling is one of several issues in Maryland’s heavily Democratic legislature where differences within the dominant party have overshadowed any partisan divide. And it is one where personalities seem to drive the process as much as policy.

Busch and Miller, who have presided over their respective chambers longer than any of their predecessors, offered divergent stories for what happened this session.

Miller said in an interview that Busch made “a handshake agreement” to pass a Senate bill on the session’s final night that would set up a statewide referendum on a Prince George’s County casino. Busch agreed to shepherd the legislation, along with several other measures needed to adopt the state budget, Miller said.

Not so, Busch said in a separate interview: “I said I’d try to work in good faith on the gaming bill, which I did.”

Busch did not bring the bill to a vote before the legislature’s midnight adjournment, in part, he said, because he wasn’t sure he had enough votes to pass it in the House, where delegates divided along geography.

Lawmakers from Anne Arundel County and Baltimore, two jurisdictions with other planned casinos, were wary of a Prince George’s site that could affect business back home.

There was another consideration: Less than 90 minutes before the session ended, Busch and Miller huddled behind closed doors, where, according to Busch, Miller said he would not pass the agreed-upon tax package until Busch passed the gaming bill.

“He might have interpreted it that way,” Miller said when told of Busch’s comments a few days days later. “But that’s not what was said.”

For those watching from the outside, including O’Malley, it was hard to tell who had agreed to what.

“Whether that was a true consensus or one that was agreed to with fingers crossed behind backs, I’m trying to sort out right now,” O’Malley said in a Thursday radio interview.

This was not the first time O’Malley found himself entangled in the politics of gambling. Five years earlier, during his first year in Annapolis, O’Malley managed to end a legislative stalemate on slot-machine gambling that had spanned the term of his Republican predecessor, Robert L. Ehrlich Jr.

For several years, Miller had aligned himself with Ehrlich in an effort to pass slots, which both men cast as an alternative to raising taxes. Busch resisted, warning of the possible “unjust enrichment” of private casino owners awarded state gambling licenses.

The tension over the issue soured relations between Miller and Busch and bred mistrust between the two Democrats, colleagues said.

In late 2007, O’Malley offered a compromise: Let voters decide the issue, and limit the state’s program to five venues in counties where local lawmakers wanted a casino.

That ruled out Prince George’s. At the time, the county was widely seen as the location best able to attract D.C. and Virginia gamblers, but a majority of Prince George’s delegates were opposed. They argued that slots would prey on the poor and increase crime and gambling addiction.

Miller was not entirely pleased with the 2007 legislation, and Busch had reservations. But in deference to the new Democratic governor, Busch secured the bare number of votes necessary to set up the slots program during a special session in 2007.

In the years since, however, the surrounding states of Delaware, West Virginia and Pennsylvania have all authorized Las Vegas-style table games, too. In the view of gambling proponents, including Miller, that put Maryland at a competitive disadvantage just as its slots casinos were starting to open.

In the summer, momentum began to build for legislation that would allow table games, such as black jack and roulette, at the state’s slots sites — and would add a casino in Prince George’s, where lawmakers were rethinking their opposition.

Shortly before the 90-day session began in January, O’Malley briefly considered sponsoring a table-games bill to gain “control” over a process that he feared could become unwieldy, an aide said.

O’Malley, who already had a full agenda, decided against it.

A Miller-backed bill that would allow both a Prince George’s casino and table games was introduced several weeks into the session.

Even so, there appeared to be signs that the relationship between Miller and Busch had thawed. In early March, Miller honored Busch with a First Citizen Award, given by the Senate each year to accomplished Marylanders. During his remarks, Miller heralded Busch’s “brilliance.”

“In retrospect, it became clear their differences were not very far below the surface,” said Sen. Brian E. Frosh (D-Montgomery).

With two weeks left in the session, Miller passed the gaming bill on a lopsided vote in the Senate, kicking the legislation to the House.

By that time, it was hard to ignore. The bill’s backers included Prince George’s County Executive Rushern L. Baker III (D), a former delegate who was advocating for a “billion-dollar” casino at National Harbor, and Baltimore Mayor Stephanie Rawlings-Blake (D).

The support of Rawlings-Blake came as a surprise, given that a Prince George’s casino could hurt business at a Baltimore venue. But the mayor — as well as Caesars Entertainment, the sole bidder for the facility — concluded that other provisions in the bill made it attractive.

Besides allowing table games at all venues, the bill also increased the share of slots proceeds that casino operators could keep.

As the bill stalled in the House, Miller’s chamber passed a second version of the legislation on the Saturday before the session ended.

By that time, Busch said, it was apparent that Miller was deliberately “slow-walking” the budget bills to gain leverage on gaming. Miller denied that, saying legitimate differences on tax policy had stalled budget negotiators.

With both the casino bill and parts of the budget plan dying on the last night of the session, speculation has turned to whether gaming will be part of the agenda in a potential special session.

Miller favors that. Busch said it would make things more difficult.