The defeat, which followed a stirring, tearful and at times very personal debate, all but ensures that the issue is dead in New York until at least 2011, when a new Legislature will be installed.

Since 2003, seven states, including three that border New York, have legalized same-sex marriage. But in two of the seven — California last year and Maine last month — statewide referendums have restricted marriage to straight couples, prohibiting gay nuptials. Pollsters say that while support generally is building for same-sex marriage, especially as the electorate ages, voters resist when they fear the issue is being pushed too fast.

In Albany on Wednesday, proponents had believed going into the vote that they could attract as many as 35 supporters to the measure; at their most pessimistic, they said they would draw at least 26. They had the support of Gov. David A. Paterson, who had publicly championed the bill, along with Mayor Michael R. Bloomberg, Assembly Speaker Sheldon Silver and the Senate Democratic leadership.

The defeat revealed stark divides: All 30 of the Republican senators opposed the bill, as did most of the members from upstate New York and Long Island. Support was heaviest among members from New York City and Westchester County and among the Senate’s 10 black members. Seven of the Senate’s 10 women voted for it.

“I’m a woman and a Jew and so I know about discrimination,” said Senator Liz Krueger of Manhattan.

Senators who are considered politically vulnerable also voted almost uniformly against the bill, including four first-term Democrats. All but one of those whose districts border or lie within the 23rd Congressional District, where the marriage issue erupted in a recent special election, opposed it. In that race, a Republican who supported gay marriage withdrew after an uproar from conservatives in her district.