He added, “We want to find out why votes switched and see what avenues are available to challenge those votes, perhaps in court.”

Same-sex marriage supporters said the vote reflected recent changes in the makeup of the legislature, the election of Governor Patrick and a lobbying effort by national and local gay rights groups that included contacting ministers, college presidents and others who were close to legislators.

“This was the focus of our national community,” said Matt Foreman, executive director of the National Gay and Lesbian Task Force. “To lose marriage here and to wage a fight in 2008 would have been extremely difficult and an extreme effort, and frankly a loss today would have been very demoralizing to the national movement.”

The few polls on the issue since same-sex marriage became legal in 2004 have generally found that just over half those surveyed supported it, roughly the same as before legalization. But about half also wanted the constitutional amendment to come before voters.

One state legislator who switched his vote was Representative Paul Kujawski, saying meetings with gay men and lesbian who are his constituents persuaded 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 Catholic neighborhood and had not previously 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 Candaras also voted against the amendment today, although she had supported it as a state representative in January. She said her vote reflected constituent views in her larger, more progressive state Senate district; her fear of a vicious referendum campaign; and the 6,800 anti-amendment e-mails, phone calls and faxes she received, one call every three minutes.