Costa Rica legalised same-sex marriage on Tuesday, becoming the first Central American country to do so and sparking an emotional response from rights campaigners as the first weddings were held overnight.

Celebrations were cancelled because of the coronavirus pandemic, but a special program about LGBT rights was broadcast on public television and online after a court ruling came into force at midnight.

"This change will bring about a significant social and cultural transformation, allowing thousands of people to marry," said President Carlos Alvarado in the program.

Costa Rica is the first Central American country to legalise same-sex marriage
Costa Rica is the first Central American country to legalise same-sex marriage AFP / Ezequiel BECERRA

Costa Rica is the eighth country in the Americas to recognise same-sex marriage -- a group that includes Brazil, Ecuador and Argentina, as well as Canada and the US.

The Supreme Court in August 2018 ruled that a ban on gay marriage was unconstitutional and gave parliament 18 months to amend the laws. It failed to do that, so the provision was automatically annulled.

"Costa Rica is celebrating today: marriage equality has become a reality in the country -- the first one in Central America," tweeted the International Lesbian, Gay, Bisexual, Trans and Intersex Association (ILGA)..

"We rejoice with you: congratulations to all those who worked so hard to make it happen!"

Gay rights activists have long campaigned for the right to marry in Costa Rica
Gay rights activists have long campaigned for the right to marry in Costa Rica AFP / Ezequiel BECERRA

Victor Madrigal-Borloz, the UN's Independent Expert on Sexual Orientation and Gender Identity, called the change "an extraordinary moment of celebration" in a tweet posted on Monday.

He expressed "gratitude to the work of so many activists, and of quiet reflection of the lives of those who lived without seeing this moment".

Moments after midnight, Dunia Araya and Alexandra Quiros tied the knot in a town northwest of the capital, San Jose. The young women, both dressed in white, took their vows before a notary wearing a face mask as part of measures to stop the spread of coronavirus.

Costa Rica has a strong Catholic tradition and has also seen a proliferation of evangelical churches in recent decades. Many followers of those denominations are opposed to gay marriage.

Alvarado, a centrist, was elected to the presidency in April 2018 by comfortably seeing off a challenge from evangelical preacher Fabricio Alvarado, who campaigned against same-sex marriage.

The Supreme Court decision complied with an opinion given by the Inter-American Court of Human Rights, declaring that homosexual couples have the same rights to marry as heterosexual ones.