TRENTON  The battle over same-sex marriage in New Jersey headed toward a legislative showdown Monday night, when a bill that would allow such unions narrowly cleared a key legislative committee and was set for a vote by the full State Senate.

The 7-to-6 vote by the Senate Judiciary Committee  which came after years of efforts by gay rights advocates and a day of emotionally charged testimony by dozens of supporters and opponents of the bill  was the first time any legislative body in the state had ever approved a gay marriage bill. The approval brought cheers from hundreds of supporters who crammed the State House committee room.

But the measure faces an uphill fight when it is put up for a vote on Thursday before the full Senate, where even supporters concede that they do not yet have the 21 votes needed to pass it. If it does pass, it will go to the Assembly, where passage is considered more likely.

Speaking to jubilant supporters after the vote, Steven Goldstein, executive director of Garden State Equality, said that gay rights advocates had a lot of work to do in the next 72 hours, but said that momentum and history were on their side.