The President-elect of Costa Rica Carlos Alvarado (C), of the Citizen Action Party, gives his victory speech during an event in Roosevelt Square, in San Pedro de Montes de Oca, Costa Rica, April 1, 2018. (Alexander Otarola/Epa-Efe/Rex/Shutterstock/Alexander Otarola/Epa-Efe/Rex/Shutterstock)

Costa Rica’s ruling-party candidate, Carlos Alvarado Quesada, appeared on track for a landslide victory over a socially conservative religious singer who ran on his opposition to same-sex marriage, according to near-complete election results Monday.

With about 95 percent of the votes counted, Alvarado, 38, a novelist and musician who has served in cabinet positions for the current president, Luis Guillermo Solís, had captured 60.8 percent in Sunday’s voting, according to the country’s ­Supreme Electoral Tribunal.

His opponent, Fabricio Alvarado Muñoz, a TV journalist, pastor and singer who had been riding momentum based on his opposition to same-sex marriage and abortion and his stance on other social issues, received 39.2 percent of the vote.

Fabricio Alvarado’s surprising rise highlighted the growing power of socially conservative and evangelical voters in the small Central American country.

The presidential election was consumed by social issues in recent weeks. This year, the Inter-American Court of Human Rights ruled that member countries should allow same-sex marriage. This decision prompted upheaval in Costa Rica’s race and improved the chances of Fabricio Alvarado, a legislator from a party supported by religious conservatives.

The Inter-American Court’s ruling “was really the equivalent of dropping an atomic bomb on the race,” said Kevin Casas-Zamora, a senior fellow at the Inter-American Dialogue in Washington and a former vice president of Costa Rica. “The whole race was transformed literally overnight.

Fabricio Alvarado Munoz, presidential candidate of the National Restoration party (PRN) and his wife Laura Moscoa greets supporters during a rally after the official election results were released in San Jose, Costa Rica April 1, 2018. (Juan Carlos Ulate/Reuters)

“The election became, de facto, a referendum on same-sex marriage,” he said.

Central American countries tend to be predominantly Catholic and socially conservative, with relatively strict laws limiting abortion. In Costa Rica, the evangelical vote has been growing in recent decades, and polls have shown that a majority of Costa Ricans oppose same-sex marriage.

The election was also unusual because it marked the first time that neither of the two traditional parties had candidates in the presidential runoff. The fragmented political landscape allowed two young, relatively inexperienced candidates a chance to seize the presidency.

Political observers said that Alvarado, of the Citizens’ Action Party, who served as labor minister, had been facing head winds because of corruption allegations against the Solís administration, which came to power in 2014 on promises to offer a new, corruption-free alternative to the traditional parties. In one major case, Costa Rican authorities have arrested several people on allegations of influence peddling related to Chinese cement imports.

“That has hurt the sitting party because it was founded as a party of ethics,” said Ludovico Feoli, director of the Center for Inter-American Policy and Research at Tulane University. “It distanced them from their original values.”