Amid cheers and camera flashes from a crush of onlookers, Gov. Martin O'Malley signed into law Thursday his bill legalizing same-sex marriage in Maryland — legislation that raises his national profile and, advocates say, gives momentum to those pushing similar measures in three states.

"The way forward is always found through greater respect for the equal rights of all," said O'Malley, giving brief remarks before signing the legislation. "If there is a thread that unites all of our work here together, it is the thread of human dignity. … Let's sign the bill."

The ceremony was held in a marble hallway on the first floor of the State House, with O'Malley and the General Assembly's presiding officers seated before a staircase packed with supportive lawmakers and advocates.

Senate President Thomas V. Mike Miller gave the crowd a thumbs-up. House Speaker Michael E. Busch beamed and pointed to supporters. After signing, all three handed out black pens — one of the first going to Del. Maggie McIntosh, the first openly gay Maryland lawmaker.

O'Malley invited the crowd to join him "across the street" in the governor's mansion for a reception open to the public.

The law doesn't take effect until 2013, and opponents have started the process to collect signatures for an attempt to repeal the measure in November.

"We're in full swing to put this on the ballot and let the people decide," said the Rev. Derek McCoy of the Maryland Marriage Alliance, which opposes the bill. "Not the governor, who brings a unique level of craftiness and tricks to the process."

Underscoring the point, Del. Emmett C. Burns Jr., a Democrat from Baltimore County, watched the signing from the far end of the corridor. He held up a pencil and said he would work to "erase" the law by throwing his energy into the referendum.

O'Malley's signature puts Maryland squarely in the middle of a widening national debate on same-sex marriage. Maine and Washington also are likely to have same-sex marriage measures on the ballot this fall.

Gay marriage advocates see 2012 as a "tipping point" for their cause nationally.

"We are moving at lightning speed in support for marriage equality," said Marty Rouse, national field director for the Human Rights Campaign, a gay rights group.

Rouse, who has worked on marriage equality laws in Massachusetts, New York and Vermont, among other states, said this year "is the most significant in American history" on the issue because so many legislatures are taking it up.

"I think every state helps every other state," Rouse said. He pointed to Rhode Island, Hawaii and Illinois as states that might be influenced by Maryland and move next on the issue.

Illinois state Rep. Greg Harris agreed. "A lot of us here in Illinois are watching what Maryland does," said Harris, a Democrat who represents part of Chicago and is pushing a same-sex marriage bill. He said his colleagues kept an eye on the "thoughtful debate" in Maryland and watched how lawmakers here "gave a lot of consideration and decided that full equality is the right thing do."

Harris sees Maryland as "the heartland" — one of the country's original 13 Colonies. He said that California and even New York are viewed as "different culturally."

Maryland's General Assembly is the fourth in the past year to approve gay marriages. The action comes on the heels of approvals by legislatures in New York, Washington state and New Jersey. (New Jersey Gov. Chris Christie vetoed the measure.) Five other states — Iowa, Connecticut, Massachusetts, Vermont, New Hampshire — and the District of Columbia also allow same-sex marriage.

The issue is a challenge for President Barack Obama, who does not support same-sex marriage but has said his views are "evolving" on the issue. White House spokesman Jay Carney said recently that the president "strongly supports the notion that the states should be able to decide this issue," but he declined to comment on recent developments in Washington state, Maryland and New Jersey.

Opponents nationally are also keeping an eye on Maryland. National Organization for Marriage founder Maggie Gallagher said the Old Line State is the one she's "least worried about." She said voters in Maryland will see the same-sex marriage bill as an example of "Democratic leaders looking to please one of their big-money constituencies."

And, she said, opponents have defeated same-sex marriage bills every time they've gone to referendum. "There is no big call for this among voters," she said.