Maryland Gov. Martin O’Malley signed legislation on Thursday that legalizes same-sex marriage, making Maryland the eighth state in the nation to legally recognize the unions.

“If there is a thread that unites the story of our people, it is the thread of human dignity,” O’Malley tweeted just moments before signing the bill.

The state would begin issuing marriage licenses to same-sex couples in January 2013 if the legislation survives a likely voter challenge. Opponents of the law, led by the Maryland Marriage Alliance and, already have begun mobilizing a petition that would force a ballot vote on the initiative in November.

“It will not happen,” Del. Emmett Burns, D-Baltimore County, said of the new law. “The real victory will be in November when the people decide.”

Opponents of the legislation must gather 55,736 signatures by June 30, the day before it takes effect, to send the law to a ballot vote, according to the Maryland State Board of Elections.

All new laws in Maryland, except for liquor and appropriations legislation, are subject to a petition for referendum vote.

Six states and the District of Columbia have legalized same-sex marriage, including Connecticut, Iowa, Massachusetts, Vermont, New Hampshire and New York.

The legislation represents a victory for O’Malley, a Democrat who made legalizing same-sex marriage one of his top legislative priorities this year. Before the 2012 session, O’Malley had never gotten directly involved in the same-sex marriage debate in Annapolis.

This year, O’Malley lobbied hard for every vote in the House of Delegates, which approved the legislation 72-67 last month. The Senate passed the measure the next week in a 25-22 vote.

O’Malley’s involvement in the legislation’s passage is expected to boost his national profile, which he is working tirelessly to build as chairman of the Democratic Governors Association.