Governor Mitt Romney immediately vowed to ask the courts to block gay marriages until voters can decide in November 2006 whether to amend the state Constitution by adding the proposed ban. The SJC decision legalizing gay marriages is set to go into effect May 17, and Romney said he wanted to avoid “confusion” created if gay couples married and then the voters banned gay marriage.

“The Supreme Judicial Court should delay the imposition of its decision until the people have a chance to be heard,” Romney said at a news conference shortly after Monday night’s vote.

Attorney General Thomas F. Reilly, however, said minutes later that he would not take Romney’s request to the SJC.

The SJC ruling would make Massachusetts the first state to allow gay couples to marry legally. The proposed consitutional amendment, on the other hand, would ban gay marriage but make Massachusetts the second state, after Vermont, to legalize civil unions.

The Legislature narrowly approved the amendment, 105-92, after a fourth intense day of debate in the past six weeks. The vote was met with a stunned hush by the gay-marriage supporters in the House gallery. It would ban gay marriage but establish civil unions that would provide the same state rights and benefits available to heterosexual couples through marriage.

Tenuous and shifting coalitions held together in the final vote, despite a series of parliamentary moves by liberal lawmakers to stop anything from moving forward. In the end, an amendment that was disliked by the political right and the political left was approved because it was the only measure that could draw the support of a majority of lawmakers.

“It took an awful lot of effort, and it is designed principally to find a comfortable consensus in the middle, recognizing that there are going to be people on both sides of the debate who hold sincere, deeply held, principled views,” House Speaker Thomas M. Finneran said shortly after the vote. “I’m thrilled with the outcome.”

A Boston Globe poll last month found that 53 percent of Massachusetts residents oppose gay marriage and 60 percent support civil unions. In addition, 71 percent of respondents said they want voters to be able to define marriage, not the courts or the Legislature.

The measure will next be considered during the 2005-06 legislative session, and would appear on statewide ballots for final approval if it is passed by lawmakers then.

Monday’s vote, however, has no immediate impact on the legal state of gay marriages.