By Pam Belluck
Jodi Hilton for The New York Times
Leah Krieger, left, and Orly Jacobovits joined gay rights advocates celebrating outside the Massachusetts State House in Boston after legislators voted against a measure that would have put gay marriage on the ballot.
BOSTON, June 14 — Same-sex marriage will continue to be legal in Massachusetts, after proponents in both houses won a pitched months long battle on Thursday to defeat a proposed constitutional amendment to define marriage as between a man and a woman.
“In Massachusetts today, the freedom to marry is secure,” Gov. Deval Patrick said after the legislature voted 151 to 45 against the amendment, which needed 50 favorable votes to come before voters in a referendum in November 2008.
The vote means that opponents would have to start from Square 1 to sponsor a new amendment, which could not get on the ballot before 2012. Massachusetts is the only state where same- sex marriage is legal, although five states allow civil unions or the equivalent.
Thursday’s victory for same-sex marriage was not a foregone conclusion, especially after the amendment won first-round approval from the previous legislature in January, with 62 lawmakers supporting it.
As late as a couple of hours before the 1 p.m. vote on Thursday, advocates on both sides of the issue said they were not sure of the outcome. The eleventh-hour decisions of several legislators to vote against the amendment followed intensive lobbying by the leaders of the House and Senate and Governor Patrick, who, like most members of the legislature, is a Democrat.
“I think I am going to be doing a certain number of fund-raisers for districts, and I am happy to do that,” said Mr. Patrick, who said he had tried to persuade lawmakers not only that same-sex marriage should be allowed but also that a 2008 referendum would be divisive and distract from other important state issues.
About 8,500 same-sex couples have married in Massachusetts since the unions became legal in May 2004. In December 2005, opponents, led by the Massachusetts Family Institute, gathered a record 170,000 signatures for an amendment banning same- sex marriage, a measure that was supported by Mr. Patrick’s predecessor, Gov. Mitt Romney, a Republican who is now running for president.
Kris Mineau, president of the institute, did not indicate on Thursday whether opponents would start a new petition drive, but said, “We’re not going away.”
“We want to find out why votes switched and see what avenues are available to challenge those votes, perhaps in court,” Mr. Mineau said.
The vote reflected changes in the legislature, the election of Mr. Patrick, and lobbying by national and local gay rights groups.
“This was the focus of our national community,” said Matt Foreman, executive director of the National Gay and Lesbian Task Force. “Frankly, a loss today would have been very demoralizing.”
It is difficult to know how support for same-sex marriage has changed since legalization because polls taken before and after have asked different questions. The most recent Massachusetts poll, in April 2007, found that 56 percent of those surveyed would oppose the amendment.
One legislator who switched his vote was Representative Paul Kujawski, Democrat of Uxbridge, saying meetings with gay and lesbian constituents convinced him that “I couldn’t take away the happiness those people have been able to enjoy.”
Mr. Kujawski, who said he grew up in a conservative Roman Catholic neighborhood and had not understood gay relationships, said, “So many people said, ‘I didn’t ask to be gay; I was born this way.’ ”
He added, “Our job is to help people who need help, and I feel the gay side of the issue needed more help than the other side.”
Senator Gale D. Candaras, a Democrat, voted against the amendment Thursday, although she had supported it as a state representative in January. Ms. Candaras said her vote reflected constituent views in her larger, more progressive Senate district and her fear of a vicious referendum campaign.
Most moving, she said, were older constituents who had changed their views after meeting gay men and lesbians. One woman had “asked me to put it on the ballot for a vote, but since then a lovely couple moved in,” Ms. Candaras said. “She said, ‘They help me with my lawn, and if there can’t be marriage in Massachusetts, they’ll leave and they can’t help me with my lawn.’ ”
Unlike several previous constitutional conventions on same-sex marriage with impassioned soliloquies, Thursday’s session took barely 10 minutes. Afterward, supporters of same-sex marriage, many in tears, erupted in standing ovations.
Katie Zezima contributed reporting.