Opponents responded by petitioning the measure to referendum. The law was suspended and put on the ballot, where voters would have the final say.

Other states had legalized same-sex marriage through legislation or via court case. In more than 30 tries, none had ever approved it by popular vote.

So began the referendum campaign. In late September, the campaign asked Hickman and Coates each to tape a television commercial.

"I said, 'Haven't we done enough?'" Hickman said. Coates persuaded him.

In separate ads, the ministers look directly into the camera. In Hickman's spot, he says: "I support this law because it does not force any church to perform a same-sex marriage if it's against their beliefs."

In Coates' ad, he says: "I would not want someone denying my rights based upon their religious views; therefore, I should not deny others' based upon mine."

A team of consultants tested the commercials with focus groups and found they had a crossover hit. Black people liked it. White people liked it. Women liked it.

"They needed to be authentic and they were authentic," said O'Malley pollster Fred Yang, who worked for Marylanders for Marriage Equality.

The group now had a campaign quiver full of commercials, but there was another problem: Supporters weren't raising the money needed to buy television time.

At the beginning of August, the campaign had only $400,000 in the bank — not enough to buy even a single week on the air. Campaign manager Josh Levin said he "sounded the alarm bell."

It rang in the governor's mansion.

"We just stayed at it," O'Malley said.

He tapped longtime ally Del. Maggie L. McIntosh, a Baltimore Democrat, to take over strategic decision-making for a campaign that was being pulled in a number of different directions.

A 64-year old lesbian from a small town in Kansas, McIntosh came of age in an era when most gays stayed quiet about their sexual orientation and hoped nobody would notice. She's risen in the General Assembly to chair the powerful Environmental Matters Committee and has a brisk, businesslike style. She shows little emotion, no ego.

The campaign's paid staff was slimmed from 24 to 16. McIntosh convened a bipartisan, all-volunteer "kitchen cabinet" to serve as a steering committee.

McIntosh began working on the question of why some national gay-rights groups were ignoring Maryland. To many out-of-staters, she learned, Maryland was a latecomer to the issue — and a disorganized one at that.

First, the state had had difficulty getting the law passed. An attempt in 2011 was pulled from the House floor when Democratic leaders were unable to muster enough votes. Then there was a history of organizational problems in its main statewide gay-rights group. And now, with the question on the ballot, advocates had little time to prepare a campaign.

And to an outside observer, the demographic picture didn't look propitious, either. There was the large African-American electorate that was traditionally hostile to gay marriage. And a significant number of Roman Catholics, with a powerful and politically active conference of bishops.

After 32 straight losses at the polls, the national groups thought victory was finally within their grasp. Elsewhere.

Maine, where a same-sex marriage campaign had been working for three years to organize and persuade voters, was attractive. Voters in Washington state had proved their willingness to support gay rights by approving a 2009 measure legalizing domestic partnerships.