New Mexico Supreme Court unanimously ruled on Thursday to legalize same-sex marriage, making it unconstitutional to deny gay and lesbian couples a marriage license.

The ruling makes New Mexico the 17th U.S. state to allow gay marriage. The governors of Hawaii and Illinois signed legislation last month to allow same-sex nuptials in their state, Reuters reported.

"Barring individuals from marrying and depriving them of the rights, protections, and responsibilities of civil marriage solely because of their sexual orientation violates the Equal Protection Clause under Article II, Section 18 of the New Mexico Constitution," Justice Edward Chavez wrote in a 31-page opinion.

The state's five justices said civil marriage should be "construed to mean the voluntary union of two persons to the exclusion of all others" and that "all rights, protections and responsibilities that result from marital relationship shall apply equally" to both same-sex and opposite-sex couples.

Six same-sex couples in New Mexico filed a lawsuit in March seeking after they were denied a marriage license.

"In terms of marriage laws, New Mexico was unique in that it was the only state in the country that neither permitted gay couples to marry nor explicitly prohibited them from doing so. The state constitution had no legislation on the books either way," MSNBC reported.

Phil Sisneros, spokesman for state Attorney General Gary King, a Democrat, told Reuters that about 10 of the state's 33 counties started processing marriage applications by same-sex couples ahead of the ruling when a county clerk in southern New Mexico independently decided to allow the unions.

The decision highlights the shifting legal and social landscape on gay marriage in the United States. Polls have shown increasing public support, and civil rights groups have prevailed at a number of courthouses and with an increasing number of state legislatures. Ten years ago, no U.S. states permitted gay marriage.

Sisneros said the decision may go into effect immediately.

"The attorney general is very pleased with the court's ruling and feels that it's something that a great deal of New Mexicans have been waiting for," he said.

This decision caps off a year that had already seen historic gains for marriage equality and it highlight he "shifting legal and social" landscape on same-sex nuptials in the United States, Reuters reported.

Eight states, including New Mexico, have "struck down barriers to same-sex nuptials this year," MSNBC reported.

"The past few years have seen an amazing show of support for the freedom to marry for all loving and committed couples," said Elizabeth Gill - a staff attorney with the ACLU Lesbian Gay Bisexual and Transgender Project, one of the groups representing the plaintiffs - in a statement. "Today's victory in New Mexico brings us one step closer to the day when marriage equality is a reality nationwide."