SANTA FE, N.M. - New Mexico became the latest state to legalize gay marriage Thursday as its highest court declared it is unconstitutional to deny marriage licenses to gay and lesbian couples.

Justice Edward L. Chavez said in a ruling that none of New Mexico's marriage statutes specifically prohibits same-sex marriages, but the state's laws as a whole have prevented gay and lesbian couples from marrying.

Same-sex couples have been subjected to a history of discrimination and violence, the justices said, and barring them from getting married violates the state constitution's equal protection clause.

"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," Chavez wrote.

The high court rejected opponents' argument that defining marriage as being between a man and a woman relates to the "important, overriding governmental interests" of having and raising children.

"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," Chavez wrote.

Under the ruling, clergy who disagree with same-sex marriage can decline to perform ceremonies for gay and lesbian couples.

New Mexico joins 16 other states and the District of Columbia in allowing gay marriage through legislation, court rulings, or voter referendums.

The ruling was a victory for gay-rights activists who had been unable to win a legislative resolution of the issue.