(CNN) -- A bill that would have legalized same-sex marriage in New Jersey was defeated in the state Senate Thursday by a vote 14-20.

New Jersey would have been the sixth state to legalize gay marriage, but advocates of the bill were seven votes shy of what was needed to move the measure on to the other state chamber, the Assembly.

The defeat came despite impassioned speeches during the debate from Democratic Sens. Sandra B. Cunningham and Nia H. Gill, both co-sponsors of the bill. They likened the fight for recognition of same-sex marriage to the struggles African-Americans faced in American history.

"This chamber, this legislature would not be this diverse and this encompassing of the citizens of the United States if someone had not said to my forefathers and mothers that we will fight for the right for our children to be equal participants in this society," Gill said.

Cunningham followed with, "As an African-American, I cannot in good conscious not support anyone's right to fight to be treated with dignity and respect."

Gay right activists had hoped the measure would pass before Democratic Gov. Jon Corzine, a supporter of the bill, turned the office of governor over to Republican successor Chris Christie, who opposes same-sex marriage.

Opponents of the legislation had argued New Jersey's civil union law provided enough protections for same-sex couples.

Sen. Raymond J. Lesniak, a Democrat and another sponsor of the bill, told CNN he was disappointed with the outcome, but he said he and other advocates were not deterred.

"I see us going into courts shortly, challenging the ban on same-sex marriage on the basis of equal protection and religious freedom protected under our Constitution, because we have many churches (that) want to perform same-sex marriages, and the state forbids them to," Lesniak told CNN.

"So I'm very confident that shortly we'll be in court, and we'll rectify the wrong that was done today."

Spectators on both sides of the issue were allowed to sit in on the proceedings. As Senate President Richard Codey, standing at the podium, announced the bill had been defeated, a chorus of cheers filled the room.