The court in Trenton gave the legislature 180 days to rewrite marriage laws to either include gay couples or create a system of civil unions for them.
"Although we cannot find that a fundamental right to same-sex marriage exists in this state, the unequal dispensation of rights and benefits to committed same-sex partners can no longer be tolerated under our state Constitution," Justice Barry Albin wrote for the 4-3 majority's decision, according to the Associated Press.
The ruling may set the state on the path first set by Vermont when it adopted civil unions for gay partners, granting them the same rights as married couples but under a different name.
Garden State Equality, New Jersey's main gay and lesbian political organization, said three state lawmakers were prepared to introduce a bill to get full marriage rights to same-sex couples.
Gay couples in New Jersey can already apply for domestic partnerships under a law the legislature passed in 2004, which gives gay couples some benefits of marriage, including health care and pension benefits for partners of state employees, reported Bloomberg News.
Democratic Gov. Jon Corzine has stated he supports domestic partnerships, but not gay marriage.
Seven gay couples seeking to marry filed the New Jersey lawsuit in 2002. A lower appeals court had ruled that same-sex marriage was not allowed under the state constitution.
Cases similar to New Jersey are pending in California, Connecticut, Iowa and Maryland.
Massachusetts is the only state that recognizes marriages between people of the same sex. Fifteen states have passed constitutional amendments banning such unions. New Jersey is one of only five states with no such statutory or constitutional ban, according to Bloomberg News.