Kenya's Deputy Prime Minister Uhuru Kenyatta appears to have won the presidential election by the tightest of margins, provisional results indicate.
After all the votes were counted he had polled 50.03% of the vote, 4,109 votes over the threshold required for outright victory.
But the official result will not come until 11:00 on Saturday (08:00 GMT).
Rival candidate Raila Odinga is likely to file a legal challenge if he loses.
One of Mr Odinga's aides told the BBC he would not concede victory and would take court action.
Mr Kenyatta won 6,173,433 votes out of a total of 12,338,667, well ahead of the prime minister, who polled 5,340,546 - or 43.28% of the vote.
However, both candidates have complained of irregularities during the course of the count, since Monday's election.
Early on Saturday, small groups of Kenyatta supporters celebrated in Nairobi, hooting car horns and singing.
If Mr Kenyatta is confirmed by Kenya's Independent Electoral and Boundaries Commission (IEBC), he could face difficult relations with Western countries.
He faces trial at the International Criminal Court (ICC) in The Hague in July for crimes against humanity.
He is accused of fuelling communal violence after the 2007 election that saw more than 1,000 people killed and 600,000 forced from their homes.
Mr Kenyatta's running mate, William Ruto, also faces similar charges.
Both men deny the accusations.
The ICC has agreed to postpone Mr Ruto's trial by a month until May after his lawyers complained of not having enough time to prepare his defence.
Countries including the US and UK have hinted that his election as president would have consequences for their relations with the Nairobi government - comments which have been dismissed in Nairobi as unwanted foreign interference in domestic matters.Technical glitches
Kenya's new electronic voting system was designed to eliminate the chance of vote-rigging and with it any risk of a repeat of the post-poll violence of 2007.
But the count has been plagued with technical glitches, including a programming error that led to the number of rejected votes being multiplied by a factor of eight. By Wednesday, the electronic system was abandoned and the count restarted by hand.
According to Kenya's election rules, the winner needs to poll more than 50% of the vote to avoid a second round run-off next month.
If the election commission confirms that Mr Kenyatta has crossed the 50% threshold by such a narrow margin, then Mr Odinga's officials say he will challenge the outcome.
The prime minister's Cord alliance had earlier complained that votes from 11 constituencies were missing, in effect leaving him more than 250,000 votes short.
Both men passed a second condition needed for victory - at least 25% of the vote in more than half of the 47 counties.