Bishop Angel Nunez speaking at the Maryland Marriage Alliance press conference on Thursday in Annapolis. Looking on is Derek McCoy, director of the group. (Mark Gail/THE WASHINGTON POST)

The cadre of Maryland lawmakers and legislative aides charged with finding votes for Gov. Martin O’Malley’s same-sex marriage bill thought they finally had them. And with 71 delegates in their corner, the counters had not a vote to spare.

Then came word that Del. Veronica L. Turner was headed to the hospital. It was two days before Friday’s planned vote, and Turner (D-Prince George’s), a key supporter, needed emergency surgery and would not be back soon.

Her absence set off a fresh scramble for one more vote to avoid a repeat of what happened last year, when a same-sex marriage bill died on the floor of the House of Delegates.

On Saturday, as they were celebrating their historic and hair-thin victory, those who championed the bill allowed that they could well have come up short again, if not for a few late-hour converts.

“I don’t think anyone was certain we had 71 votes until the moment it flashed on the board,” said Del. Justin D. Ross (D-Prince George’s), who led the House’s “whip” operation on the bill sponsored by O’Malley (D).

The bill, which cleared the House on Friday with one vote to spare, now goes to the Senate, where similar legislation passed last year. Opponents have vowed to petition the bill to the ballot, which could give voters the final say in November.

As momentum grows nationally for same-sex marriage, Friday’s margin underscores how divisive the issue remains, even in a heavily Democratic state, and how out of reach gay nuptials remain in many parts of the country.

O’Malley’s push began in the summer, when he agreed to sponsor this year’s bill in the wake of last year’s failure. He, his aides and supportive lawmakers — including seven gay House members — engaged in countless calls, visits and even prayer sessions with wavering delegates.

The Human Rights Campaign, a national gay-rights group, said Saturday that it had spent more than $500,000 on efforts in Maryland, much of that focused on making targeted lawmakers aware of support for same-sex marriage in their districts.

Despite the months-long campaign, Friday’s outcome became possible only with the late support of a pair of Republicans and a handful of Democrats who opposed last year’s bill.

One of those, Del. John L. Bohanan (D-St. Mary’s), waited until 6 a.m. Friday to send House Speaker Michael E. Busch (D-Anne Arundel) a text message notifying him of his decision to vote for the bill.

Bohanan said he changed his position after long reflections while driving back and forth to Annapolis last week. “Once I began to look at this through the eyes of my own kids and other young people, it became pretty clear,” said Bohanan, who has four sons ranging in age from 17 to 21. “You want them to have love, and if that’s how they want to express it, you want them to be able to do it openly.”

Bohanan said he cast his vote also thinking the issue will go to referendum.

No “yea” vote was more surprising than that of Del. Tiffany Alston (D-Prince George’s), who was among the last to indicate her planned support.

Alston was a co-sponsor of last year’s bill but withdrew her support in dramatic fashion — after skipping a scheduled committee voting session. House leaders started engaging her seriously on the issue after Turner’s hospitalization.

Alston, who said her opposition last year reflected the majority view of her constituents, shared some proposed amendments to this year’s bill with House leaders. The aim was to ensure that no same-sex marriages would occur until any litigation was resolved over the referendum process.

On Thursday night, Alston met with O’Malley.

Later that evening, her amendments — and potential support of the bill — were among the topics at a strategy session in the governor’s lobbying office that stretched past midnight, according to participants. O’Malley was there for much of the meeting, which also included a few of his aides, Busch staffers and some Democrats pushing the bill.

Underscoring the uncertainty of the vote count, the meeting included discussion of a “Plan B” — trying to pass a civil unions bill instead.

Even as lawmakers adopted two of Alston’s amendments Friday afternoon, not all of her colleagues were confident she would vote for the bill, given her track record of a year ago.

But she did.

“I just felt like as a state it was time for us to allow the people to get involved in the issue,” Alston said Saturday, referring to a referendum.

In recent months, some same-sex marriage supporters grumbled that Busch did not insist that other Democrats in leadership positions vote for the bill. The 26 Democrats who voted against the legislation included three House committee chairmen.

One leadership team member who did switch sides was Del. Marvin E. Holmes Jr. (D-Prince George’s), chairman of the House Democratic caucus.

After a highly contentious meeting of Democrats on Thursday morning, Holmes said he asked O’Malley to speak to the group about a source of division: a recent speech in which O’Malley’s wife referred to some same-sex marriage opponents as “cowards.”

O’Malley appeared that afternoon. Holmes said he decided to support the bill after that but not because of that. He said because his district is evenly split on gay nuptials, he thought voting for it would allow the issue to be settled in a referendum.

Friday’s tally would have fallen short without at least one Republican vote as well. After weeks of outreach, O’Malley got two: Robert A. Costa of Anne Arundel County and A. Wade Kach of Baltimore County.

Kach told his colleagues that in January he had been certain he would vote against the bill. It wasn’t until a hearing a week before the vote that he changed his mind, after testimony from gay couples with children.

“As a pro-life Republican, I believe it’s my responsibility to make sure children are taken care of,” he said. “I left that hearing a changed person.”