Costa Ricans may have to wait for two weeks for presidential election results to be declared, with the two leading candidates virtually neck-and-neck.
Oscar Arias is seen by many as untainted by recent scandals
With one of the closest finishes in the country's history, officials said the result would hang on a manual recount.
With more than 86% of votes counted, ex-President Oscar Arias had 40.5%, compared with 40.2% for Otton Solis - a difference of fewer than 5,000 votes.
Both men said they would wait for the final results before claiming victory.
Mr Arias, 65, who won the 1987 Nobel Peace Prize, had enjoyed a big lead over his rival in opinion polls.
But far from the easy victory that had been predicted for him, Sunday's election became the hardest-fought vote in the last four decades, says the BBC's Gilberto Lopes in Costa Rica.
"We are going to wait until the end, until the electoral tribunal has processed all the votes. With such a small difference, anything can happen," said Mr Solis, who heads the Citizens' Action Party.
Mr Arias, from the National Liberation Party, was also cautious: "I cannot claim victory yet. We are just going to postpone our victory celebrations for 24 hours."
The top two candidates go through to a second round if the winner does not get at least 40%.
The election comes amid wide disillusionment with politics after a string of corruption scandals in Costa Rica.
Voting stations opened at dawn on Sunday for the country's eligible 2.5 million voters, but turnout was 65% - the lowest in Costa Rican history.
However, officials said the election had proceeded peacefully.
Otton Solis wants some of the Cafta deal to be renegotiated
Activists for the main parties drove through the streets of the capital, San Jose, honking horns and waving flags in a bid to drum up support.
"This is a cold election because people are disillusioned with our politicians," Elena Hidalgo, a 52-year-old lawyer waiting to vote in San Jose, told AP.
Three former presidents have been accused of taking illicit payments from foreign companies. Two of them are on trial.
Free trade deal
Correspondents say many Costa Ricans see Mr Arias - who was president between 1986 and 1990 - as a politician untainted by the recent scandals.
But his critics describe him as arrogant.
Mr Arias won the Nobel Peace Prize in 1987 for spearheading talks that led to the end of civil wars in Nicaragua and El Salvador.
He says he wants Costa Rica to join the Central American Free Trade Agreement (Cafta) with the US.
Costa Rica is the only country in the region which has not ratified the deal which is set to come into effect later this year.
Mr Solis wants some of the deal to be renegotiated, arguing that in its current form it would exacerbate poverty and hurt small-scale farmers.
He is hoping to ride the left-wing wave sweeping through some Latin American countries.