© Quinn Dombrowski via Flickr

The winner of the presidential election was Carlos Alvarado Quesada, who has pledged to bring same-sex marriage to the country.

Fabricio Alvarado Muñoz, a homophobic pastor who mostly based his presidential bid off of blocking same-sex marriage, has lost the Costa Rican presidential election.

Muñoz initially entered as a fringe candidate, but quickly gained support, and went into the final run-off as a fringe favourite. But with 95% of the vote counted last night, he was losing by 39.2 percent of the vote to Quesada’s 60.8.

Because of Muñoz’s popularity some commentators said the presidential election was also a referendum on the legalisation of same-sex marriages.

Earlier this year, a ruling by the Inter-American Court of Human Rights (IACHR) said that 20 Central, Caribbean and Southern American countries that had signed its American Convention on Human Rights needed to legalise same-sex marriage. Costa Rica set about making it legal, but the day before the country’s first same-sex wedding was set to take place, a government agency stopped it.

Related: Lebanese political party vows to decriminalise gay sex if they win the country’s next election

But thankfully, with Quesada in power, same-sex marriages could soon be coming to the American country. Speaking to supporters, Quesada said: “My commitment is to a government for everybody, in equality and liberty for a more prosperous future.

“There is much more that unites us than divides us.”

Quesada then wrote on Twitter: “This campaign demonstrated the power of love. That is the strength that should unite us.

“I will lead a government for all and all. That shelters all people, without any distinction.”

In conceding, Muñoz said: “We are not sad, because we made history, because our message touched the country’s deepest nerves.”

Carlos Alvarado Quesada will take over as Costa Rica’s president in May.