BALTIMORE -- Maryland voters passed gay marriage Tuesday, making the state one of the first to approve it at the ballot box.

The measure passed 51 percent to 49 and will take effect Jan. 1.

Maryland is among the first states to legalize gay marriage at the voting booth out of the 32 that have put it to a vote in the last 14 years. Maine also passed it Tuesday night, and it was on the ballot in Minnesota and Washington.

The state is the eighth -- ninth including D.C. -- and the first below the Mason-Dixon Line to pass the measure.

The result is a major win for Gov. Martin O'Malley, who made gay marriage a cornerstone of his administration. He first introduced a bill legalizing same-sex marriage in 2011, which failed in the state legislature.

"This is the civil rights issue of our time," Baltimore Mayor Stephanie Rawlings-Blake said early Wednesday morning. "We know the future of our country is a future of equality and dignity."

The law approved by voters on Tuesday placed a heavier emphasis on protecting religious freedom than the one that failed, specifying that no religious institution would be required to perform marriages that oppose its beliefs.

"Religious institutions shouldn't be forced to marry anyone outside of the bounds of what their belief systems are, but ... I don't just think anybody in the government should tell people that they can't get married," said Baltimore resident Sarah Hedges, who said she voted for the measure.

However, opponents of the measure, like Potomac resident Bill Gold, said they weren't convinced by the additions to the bill.

"I just feel that marriage is between a man and a woman," Gold said Tuesday while waiting in line to vote. "I'm Jewish, so I definitely believe that. That's our philosophy, that's our belief."

After the measure narrowly passed the General Assembly in February and O'Malley signed it into law in March, the Maryland Marriage Alliance successfully collected enough signatures from Maryland voters to get it on the November ballot.

The ensuing campaign flooded out-of-state funds into local advertising, and the measure's supporters received numerous celebrity endorsements. By last count, the campaigns raised more than $7 million and spent more than $4 million on TV, radio and print ads, flyers, yard signs and direct mailings.