The bill narrowly passed the House of Delegates on Feb. 17 and the state Senate less than a week later, and it now faces a campaign by its opponents to put it to a public vote in November. If that challenge fails, the law will be enacted Jan. 1.
After a similar measure died in the House of Delegates last year, O'Malley, a Democrat, announced in July he would sponsor a new one. This year's version included protections for churches and other religious institutions, allowing them to opt out of holding same-sex weddings.
During debate on the bill, opponents questioned whether the protections were strong enough, and a last-minute attempt to broaden the exemption was defeated in the Senate.
The Maryland Marriage Alliance, a coalition of religious groups, is leading the campaign to overturn the law at the polls. The alliance - which is gathering petition signatures, the first step in the referendum process - is linked to the powerful National Organization for Marriage, a group formed to fight for California's challenged ban on same-sex unions.
Derek McCoy, executive director of the alliance, said in a statement earlier this week, "It is clear that while the opponents of marriage have been seeking influence from an elite group of politicians and supporters, the average citizens of Maryland continue to believe in the time-tested, unalterable definition of marriage."
Marylanders for Marriage Equality, a coalition backing same-sex marriage rights, expects the efforts to get the referendum on the ballot to succeed and is mounting a campaign to uphold the law.
"I celebrate with my gay friends today," Ezekiel Jackson, a political organizer with Service Employees International Union Local 1199, part of the group, said in a statement. "But we are clear that a referendum may be on the horizon. There is something uneasy about total strangers deciding whether my gay friends can marry and whether their kids can be protected equally under the law."