He will face Carlos Alvarado of the centre-left Citizen's Action Party (PAC) in the second round on 1 April.
The election was dominated by the issue of same-sex marriage, after a court ruled that it should be recognised.
Fabricio Alvarado surged ahead after promising to oppose the ruling.
With almost all the ballots counted, the evangelical preacher had 24.8% of the vote, while Carlos Alvarado had 21.8%. The two candidates are not related.
- Right-wing evangelical preacher
- 42 years old
- Vocal opponent of same-sex marriage
- Author of evangelical songs such as Tu amor es todo (Your love is everything)
- Says family is "the fundamental basis of society"
- Centre-left fiction writer and former government minister
- 38 years old
- Backs same-sex marriage
- Sang in a progressive rock band
- Running on a promise to rejuvenate the governing party
They will now try to win over the people who cast their votes for the 11 candidates who did not make it into the second round.
Third-placed Antonio Álvarez Desanti said he had been left blind-sided by the quick rise of Fabricio Alvarado, who until now was the only lawmaker representing his right-wing National Restoration Party (PRN) in Costa Rica's legislative assembly,
"Hand on heart, [speaking] frankly and openly, I did not see it coming that Fabricio would go from 3% to 26% in just three weeks," he said.
Fabricio Alvarado was buoyed by his opposition to a ruling by the Inter-American Court of Human Rights requiring Costa Rica and other member states to recognise same-sex marriages.
The ruling caused outrage among socially conservative Costa Ricans who saw it as an interference in the customs and laws of the Central American nation.
In his victory speech on Sunday, Fabricio Alvarado said that "there's nothing more progressive than defending life and family".
He will now be pitted in the second round against Carlos Alvarado, who has been courting young voters in particular.
Image copyrightREUTERSImage captionCarlos Alvarado is only 38 but has already served as a government minister
Carlos Alvarado has been criticised for his limited experience in government despite having held a ministerial post in the centre-left government of outgoing President Luis Guillermo Solís.
He has dismissed the criticism, saying that people should be judged by their actions, not their age and by citing his commitment to eradicating extreme poverty during his time as minister for social inclusion.
More about: CostaRica