Gay marriage is already legal in over a dozen nations worldwide, but Costa Rica may yet set a remarkable precedent – by being the first to allow same-sex unions by mistake.

This week, the Costa Rican Legislative Assembly voted for a change to its “Law of Young People”, which covers social services and marriage laws. It was only once the bill had passed did unwitting conservative lawmakers realise that their liberal counterparts had inserted language that could open the door to civil unions for gay couples.

The controversial wording was written into the legislation by José María Villalta, a member of the left-wing Frente Amplio party.

Download the new Independent Premium app Sharing the full story, not just the headlines

“During the discussion in the first debate, we explained that the Law of Young People should be interpreted with this sense of opening to gays and no one objected,” Villalta said afterwards. Given the lack of perceived opposition to his amendment, he proceeded to insert it into the bill. The text, which previously stated that only marriages between a man and a woman would be recognised, now extends “the right to recognition without discrimination contrary to human dignity.”

Outraged Christian conservatives have demanded that Costa Rican President Laura Chinchilla, pictured, veto the legislation when it crosses her desk. But Ms Chinchilla has refused to oppose the bill’s passage. Once the bill is approved by the President, it will likely face challenges in the country’s courts, which it is expected to lose.

Gay rights activists in Costa Rica have nonetheless hailed the week’s events as a turning point for their cause. Marco Castillo, the leader of Movimiento Diversidad (“Diversity Movement”), told the Tico Times, “It’s a big step forward for gay rights in Costa Rica.”