A day after the polls in the Central American country, only 3648 votes separated centrist candidate Oscar Arias, a former president and a Nobel Peace prize winner, and his centre-left rival Otton Solis.
At midday on Monday with 87.3% of ballots counted, Arias led with 40.5% of the vote against 40.3% for Solis, prompting electoral council president Oscar Fonseca to announce a two-week manual recount of all of the ballots.
"Whatever happens, we will have to have a manual count of the ballots and that could last up to two weeks," Fonseca told reporters.
The announcement of a second count came after numerous government unions demanded that the tribunal have a vote-by-vote count before announcing the winner.
Arias acknowledged that Costa Rica is divided and said he would maintain a dialogue and seek accords with the opposition if he wins the election.
"This is a polarised society and if I triumph, I will have to pay a lot of attention to the 50% of Costa Ricans who did not vote for me," he told reporters.
Thirty-five percent of the 2.5 million electorate stayed away from voting, in an apparent protest at corruption scandals that have rocked recent Costa Rican governments.
The unofficial election results were contrary to all of the pre-election opinion polls, which had Arias favoured by a solid ten to twenty percentage points.
Analysts said the result would be the tightest in Costa Rica's election history. To be elected president in Costa Rica, a candidate needs to top 40% of the total vote. If two candidates are both over 40%, the one with the most votes wins.
Centre-left candidate Otton Solis
has come a close second
The election focused on issues of corruption in previous governments as well as the contentious issue of joining the proposed Central America Free Trade Accord (CAFTA) with the United States.
Costa Rica is the only country not to have ratified the accord.
Arias, who was president from 1986-90, backs the accord, while Solis wants it renegotiated.
A business tycoon with coffee and sugar plantations and interests in a financial group, Arias, 65, won the 1987 Nobel prize for his efforts to mediate in conflicts in Central America.
Solis was a minister under Arias but left their National Liberation Party in 2000 to protest its turn to the right. He ran for president in 2002 and now opposes the free-market route to prosperity.
The elections on Sunday also saw voters choosing two vice- presidents, representatives and local officials.
"This is a polarised society and if I triumph, I will have to pay a lot of attention to the 50% of Costa Ricans who did not vote for me"
In the legislature, Arias' National Liberation Party won 25 of the 56 seats, compared to 17 or 18 for Solis' Citizen Action Party.
A third party, the conservative United Social Christian Party, suffered from corruption scandals involving leading party figures.
Two ex-presidents, Rafael Angel Calderon and Miguel Angel Rodriguez, were charged with taking bribes in 2004.
Calderon is suspected of taking money from a Finnish medical company and Rodriguez from French engineering firm Alcatel.
Both are out of prison on bail awaiting their trial, but the impact on the USCP has been devastating. Its presidential candidate, Ricardo Toledo, earned only 3.5% of the vote in the preliminary count, and the party only won four legislative seats.
Another ex-president, Jose Maria Figueres, is also facing accusations that he took money from Alcatel. He is refusing to give evidence to Congress, with critics saying that he fears being arrested.
The corruption storm has overshadowed the real debate for most Costa Ricans, the country's widespread poverty.