Amid a pep-rally atmosphere, Massachusetts legislators on Wednesday overwhelmingly rejected an attempt to halt same-sex marriages here -- showing how quickly gay nuptials have moved from being a court-ordered imposition to a powerful political cause.

By a vote of 157 to 39, members of the House and the Senate meeting together voted down a proposed constitutional amendment that would have eliminated the same-sex marriages legalized two years ago and replaced them with "civil unions" for gay couples.

Instead, the vote leaves same-sex marriage as the status quo in Massachusetts, and it now seems likely to remain so until at least 2008.

But, in a broader sense, the vote also illuminated how widely Massachusetts has diverged from much of the nation, where several dozen states have passed laws limiting marriage to heterosexual couples. California's lawmakers have passed legislation legalizing same-sex marriage. It is now sitting on the desk of Gov. Arnold Schwarzenegger (R), who has said he will veto it.

Politicians here credit the weddings themselves with shifting the political momentum, saying their growing ordinariness has defused some of the opposition.

"The difference is that we have marriage," said state Sen. Jarrett T. Barrios (D) after the vote, while other supporters screamed and cheered nearby in a rally under a mural of the Boston Tea Party. "We've got a world that hasn't changed."

The issue of same-sex marriage has been on the front burner of politics here since November 2003, when the state's Supreme Court ruled in favor of seven same-sex couples who had pressed for the right to wed.

The court found that "the right to marry means little if it does not include the right to marry the person of one's choice" -- making Massachusetts the first state to offer gay couples more than civil unions.

Weeks of emotional debate followed, as some state legislators sought to nullify the court's ruling. Finally, plans were made to amend the state constitution to permit civil unions but ban marriage. But such amendments require votes in two successive sessions of the state legislature.

The proposal passed in March 2004 but still required another vote; it was the measure turned down on Wednesday.

In the meantime, the weddings began. Since the first one on May 17, 2004, more than 6,100 gay couples have wed, accounting for about 17 percent of all the state's weddings during that period.

Each one made the idea of same-sex marriage more acceptable, observers say.

The differences were noticed by politicians, who say they started getting more letters in favor of the marriages, and by public-opinion pollsters, who noted in March that 56 percent of state residents believed same-sex marriages should be allowed.

"It's one of those areas of politics where people have become accustomed to something that was once radical," said Julian E. Zelizer, a history professor at Boston University. "It's just normative at this point."

By the time Wednesday rolled around, support for the civil-unions measure had collapsed. Forces in favor of same-sex marriage were feeling too confident to compromise, while opponents had united behind another constitutional amendment that would eliminate same-sex unions of any kind.

Gov. Mitt Romney (R), who is contemplating a presidential bid in 2008, favors a complete ban on any legalization of same-sex unions. In an interview this week, he said he has concerns about whether children brought up by a same-sex couple could develop normally.

"The ideal setting for raising a child is where there is a male and female," Romney said.

Even though the amendment under consideration was known to be dead beforehand, its killing took on a party atmosphere.

First, there were speeches, from legislators who compared Massachusetts's place in the national debate to the radical role the state's Minutemen played in the Revolutionary War.

"We are as out of step today as we were on the village green in Lexington and Concord," said state Sen. Edward M. Augustus Jr. (D). "Massachusetts has always been the conscience of the nation."

Christopher Mason, center, celebrates with Robyn Maguire, left, and Amy Mello in Boston after the state legislature overwhelmingly rejected a measure that would have eliminated the same-sex marriages that were legalized in 2003.