Updated

An international court ruling saying Costa Rica should allow same-sex marriage has upended the Central American nation's presidential race, turning an evangelical candidate who opposes it from an also-ran with just 2 percent in the polls into the leading contender in Sunday's vote.

Following last month's decision by the Inter-American Court of Human Rights, Fabricio Alvarado, a 43-year-old journalist with a prominent career as a preacher and Christian singer, vaulted to 16.9 percent in a survey published Jan. 31 by the University of Costa Rica's Center for Research in Political Sciences, or CIEP.

Alvarado's nearest rivals were Antonio Alvarez of the National Liberation Party with 12.4 percent, and Carlos Alvarado — no relation — of the governing Citizens' Action Party with 10.6 percent. If no candidate tops 40 percent in the vote, the first two finishers advance to a runoff scheduled for April 1.

The same poll showed that just over two-thirds of Costa Ricans oppose the court's ruling, which also tells the country to grant same-sex couples rights such as the ability to adopt children and receive inheritances and other benefits from their partners.

For deeply Roman Catholic Costa Rica, the gay marriage ruling came as an "external shock" to the campaign, political analyst Francisco Barahona told The Associated Press.

"Fabricio is a young candidate, well-spoken with a good on-camera presence, but he was also the only one who reacted in radical opposition to what the Inter-American Court proposed," Barahona said. That "put him on the radar for a good portion of the conservative electorate."

Alvarado has called the ruling a "sovereign violation" and an "external imposition" and even floated the idea of withdrawing from the OAS-sponsored rights court, which is hosted in Costa Rica's own capital, San Jose.

That won tacit approval from evangelical and Catholic leaders who, while prohibited from explicitly participating in elections in the country, have called on voters to back candidates with "Christian values."

About 76 percent of Costa Ricans identify as Roman Catholic and 14 percent as evangelical, according to the CIA World Factbook.

Ana Cecilia Sanchez, a 53-year-old office administrator, is one of many who say they are undecided but would not vote for a candidate who supports gay marriage.

"For me the issue of values and principles is very important for all of society, because family is the basis of society. ... You ask yourself what will happen to Costa Rica if Christian values are lost," Sanchez said.

Adrian Pignataro, a political scientist at the University of Costa Rica, said the country has seen a marked erosion in party loyalty and this election has exposed a social divide between secular and religious values.

"It's not that this division is new, they are values that were there before, but in this campaign they were activated by an event and one party strategically came out in favor," Pignataro said.

Pignataro sees a parallel to the 2006 election, when voters were polarized by opposing visions on the economy: one that favored opening to the world amid trade negotiations with the United States, and another more protectionist approach.

Carlos Alvarado, who is not related to Fabricio, is also a young candidate at just 38, a journalist by profession who began his political career as communications director for the Citizens' Action Party and served as labor minister under current President Luis Guillermo Solis.

His candidacy has been marred by corruption scandals involving people close to Solis' government and a lingering deficit problem.

But as the only major candidate openly backing same-sex marriage, Carlos Alvarado also saw his poll numbers rise about 5 percent recently as he attracted socially liberal voters who oppose Fabricio Alvarado's anti-gay marriage stance.

Alvarez, a 59-year-old agricultural businessman, two-time president of the Legislative Assembly and former Cabinet minister under the first presidency of Oscar Arias in 1986-1990, is running on promises to create 150,000 jobs, decrease the deficit and modernize public transportation.

Alvarez has also opposed same-sex marriage, while supporting the idea of recognizing certain other rights for gay couples.

Lawyer and former Security Minister Juan Diego Castro was a front-runner as recently as December as a tough-on-crime candidate. But he fell to fourth in polls as some voters were turned off by his direct attacks during debates and after the gay marriage ruling in January.

Sunday's outcome is very much up in the air with more than two-thirds of likely voters undecided, according to the CIEP poll.

"None of them really grabs my attention," said Berlioth Hidalgo, a 35-year-old cleaning worker who has not yet fixed on any candidate. "In this country it's only fights, corruption, you don't know where the money goes, lots of poor children."

Voters will also be selecting the 57 delegates that make up the Assembly.