The New Mexico Supreme Court on Thursday ruled that gay marriage is legal in the Land of Enchantment.

The court said in an unanimous decision that it is unconstitutional to deny marriage licenses to gay and lesbian couples.

"We hold that the State of New Mexico is constitutionally required to allow same-gender couples to marry and must extend to them the rights, protections, and responsibilities that derive from civil marriage under New Mexico law," Justice Edward L. Chavez wrote in the decision.

Many counties in New Mexico had already been issuing marriage licenses to gay couples, setting up the state Supreme Court to decide whether it was legal or not. The state didn't explicitly ban or allow same-sex marriage, leaving the issue in limbo.

New Mexico becomes the 17th state to legalize gay marriage (map here) and the first in the American Southwest. Illinois and Hawaii did the same last month. Gay marriage is also legal in the District of Columbia.

Gay rights groups were quick to hail the ruling.

“The court is entirely correct that denying lesbian and gay couples the same rights as everyone else is fundamentally unjust,” said Chad Griffin, president of the Human Rights Campaign. “Regardless of where you live, all people should have the ability to marry the person they love, and now the legislature must not do anything to turn back the clock in the Land of Enchantment.”

Opponents of gay marriage accused the court of judicial activism by effectively creating a new law without a constitutional basis.

“The New Mexico Supreme Court is the final word on the meaning of the New Mexico state constitution – a final word that is short of the will of the New Mexico people themselves," said Ken Klukowski of the Family Research Council. "The court was acting as a legislature, not as a court.”

The justices noted that many states previously banned interracial marriages as well. They said that, in order for the state to ban gay marriage, it would have to show that it had a substantial interest in preserving traditional marriage.

Supporters of a ban argued that same-sex couples cannot procreate, but the court didn't buy that argument.

"Procreation has never been a condition of marriage under New Mexico law, as evidenced by the fact that the aged, the infertile, and those who choose not to have children are not precluded from marrying," the justices wrote.

Updated at 5:26 p.m.

New Mexico Supreme Court decision legalizing same-sex marriage

Map: State-by-state status of same-sex marriage in the U.S. 

GALLERY: Countries where gay marriage is legal