The ruling, published on Friday, followed a case brought by a gay Peruvian citizen who sued the registration office for refusing to record her 2019 marriage overseas, saying her constitutional rights were violated.

Representatives of the office were not immediately available for comment.

Peru is one of the few countries in Latin America that has not recognized same-sex marriage, though it is not illegal to be gay.

A 2021 survey by Ipsos found that 68% of people in Peru were in favor of same-sex marriage or other legal recognition. However, 61% disapproved of gay people in public office.

The Lima court ordered the records office to "proceed with the registration" of the woman's marriage, the Superior Court of Justice of Lima said on Twitter.

The court declared "inapplicable" an article of the Peruvian Civil Code of 1984 on the family, which refers to marriage as the voluntary union between man and woman.

It is likely that an appeal against the ruling will be lodged.

In 2020, a gay couple took Peru to the Inter-American Court of Human Rights after they lost a bid for recognition of their Mexican marriage certificate.

At the time, the constitutional court ruled that the civil registry of Peru only recognizes the marriage between a man and a woman.

Other countries in South America, including Argentina, Uruguay, Brazil and Colombia, have legalized gay marriage in recent years.

(Reporting by Marco Aquino; writing by Isabel Woodford; editing by Robert Birsel)