Costa Rica's Supreme Court has ruled that the country's same-sex marriage ban is unconstitutional and discriminatory.
The court ruling gives the country's legislators a time limit of 18 months to change the current law.
The president welcomed the ruling, saying he wants to guarantee "no person will face discrimination for their sexual orientation".
However many lawmakers are evangelicals who strongly oppose gay marriage.
A Supreme Court judge, Fernando Castillo, told a press conference on Wednesday that the ban will automatically cease to legally exist in 18 months, even if no action is taken by the legislature.
The legislative chamber has 57 seats – 14 of which are held by evangelical members.
Late Wednesday's ruling complies with a judgement issued in January by the Inter-American Human Rights Court that said same-sex marriage should be recognised by all of its signatory members.
Enrique Sanchez, the country's first openly gay legislator, told AFP that he did not believe the assembly would work out a law change between themselves.
He is a member of the Citizen Action Party, led by President Carlos Alvarado who came to power on a pro-LGBT platform.
President Alvarado is a former rock singer and novelist, who won the presidential run-off in April following a campaign where LGBT rights became a key issue.
He beat evangelical pastor opponent Fabricio Alvarado, who vowed to defy the Human Rights Court's rulings on same-sex rights.