Ivory Coast's Constitutional Council has overturned earlier poll results and declared President Laurent Gbagbo the winner of Sunday's run-off.
The electoral commission head had said opposition candidate Alassane Ouattara had defeated Mr Gbagbo.
The UN chief, the US, the EU, and former colonial power France have also endorsed Mr Ouattara as the winner.
The presidential poll was intended to reunify the world's largest cocoa producer after a civil war in 2002.
The two candidates represent the two sides of the north-south divide that exists religiously, culturally and administratively, with the northern half still controlled in part by the former rebels.
On Friday Paul Yao N'Dre, chairman of the Constitutional Council, which validates election results, said Mr Gbagbo had won a little more than 51% of the vote.
He said results in seven regions in the north, where Mr Ouattara draws most of his support, had been annulled.
"The irregularities are of such a nature that they invalidate the vote," Mr N'Dre, an ally of President Gbagbo, said on national television.
But the head of the UN mission in Ivory Coast said it accepted the unitial results announced by the electoral commission and regarded Mr Ouattara as the winner.
The mission said it had received reports of violence in parts of the west and north on election day, but that overall the voting seemed to be peaceful and any irregularities did not overturn Mr Ouattara's lead.
UN Secretary General Ban Ki-moon also endorsed the original result on Friday, and congratulated Mr Ouattara "on his election".
US President Barack Obama and France's Nicolas Sarkozy issued similar statements, as did EU foreign policy chief Catherine Ashton who urged "all parties to the electoral process to respect the will of the people".
Mr Ouattara has declared himself the new head of state.
The BBC's John James in Abidjan, the country's main city, says the Constitutional Council's decision has come as a shock to many, especially the opposition.
Youths from the opposing camps took to the streets in Abidjan and other towns, throwing stones and burning tyres.
The military has closed the borders and international news sources are suspended. An overnight curfew is in place.
On Friday an aide to Mr Gbagbo told Ivory Coast's state-run TV that he would call for the "immediate departure" of the UN representative in the country, Choi Young-jin.
The African Union said it was "deeply concerned" by the developments.
There have been dramatic scenes since Sunday over the declaration of the results.
On Tuesday, Mr Gbagbo's representative in the electoral commission tore up the first batch of results as the commission's spokesman was about to announce them.
The electoral commission head, Youssouf Bakayok, then went ahead with an announcement on Thursday, speaking under armed guard at a hotel rather than from the commission's headquarters, declaring Mr Ouattara the winner with 54% of ballots cast.
Not long afterwards, Mr N'Dre said that, as the announcement had come after Wednesday's legal deadline, those results were "null and void".
Both the army and UN peacekeepers have been patrolling the streets of Abidjan since Sunday.
At least four people have been killed in election-related clashes in Abidjan this week.