A candidate indicted for crimes against humanity has been declared winner of Kenya's presidential election today by just 8,400 votes.
Uhuru Kenyatta, the son of Kenya's founding president, faces trial after the disputed 2007 presidential vote that unleashed a wave of tribal blood-letting.
With the 51-year-old in the top job, Kenya will become the second African country after Sudan to have a sitting president indicted by the International Criminal Court.
The U.S. and other Western powers, big donors to the east African nation, said before the vote that a Kenyatta win would complicate diplomatic ties with a nation viewed as a vital ally in the regional battle against militant Islam.
After saying Kenyatta secured 50.07 per cent of the votes, just achieving the more than 50 per cent needed to avoid a second round, the chairman of the Independent Electoral and Boundaries Commission, Issack Hassan, announced: 'I therefore declare Uhuru Kenyatta the duly elected president of the Republic of Kenya.'
Shortly afterwards he handed a certificate of the results to Kenyatta, who had arrived after the declartion. Kenyatta thanked him.
Many in the election centre cheered, although celebrations started in the early hours of Saturday after provisional results showed Kenyatta's victory.
Supporters thronged the streets of Nairobi and his tribal strongholds, lighting fluorescent flares and waving tree branches and chanting 'Uhuru, Uhuru'.
Speaking before the formal declaration, a close adviser to Odinga said his candidate would challenge the result if Kenyatta was declared winner.
'He is not conceding the election,' Salim Lone told Reuters, speaking on behalf of Odinga. 'If Uhuru Kenyatta is announced president-elect then he will move to the courts immediately.'
Odinga's camp had said during tallying that the ballot count was deeply flawed and had called for it to be halted. But they promised to pursue any disputes in the courts not the streets.
The election commission, plagued by technical problems that slowed the count, took five days to announce the result.
Kenyatta achieved the 50 per cent mark by a tiny margin of about 8,400 votes out of the more than 12.3 million that were cast.
Both sides relied heavily on their ethnic groups in a nation where tribal loyalties mostly trump ideology at the ballot box. Kenyatta is a Kikuyu, the biggest of Kenya's many tribes, Odinga is a Luo. Both had running mates from other tribes.
John Githongo, a former senior government official-turned-whistleblower, urged the rival coalitions, Odinga's CORD and Kenyatta's Jubilee, to ensure calm.
'Jubilee and CORD, what you and your supporters say now determines continued peace and stability in Kenya. We are watching you!' he said on Twitter.
How Western capitals deal with Kenya under Kenyatta and the extent they would be ready to work with his government will depend heavily on whether Kenyatta and his running mate William Ruto, who is also indicted, cooperate with the tribunal.
Both Kenyatta and Ruto deny the charges and have said they will work to clear their names, though Kenyatta had to fend off jibes during the campaign by Odinga that he would have to run government by Skype from The Hague.
'Until now, Kenyatta has been cooperating with the court and we do hope this will continue,' said Fadi El-Abdallah, spokesman for the Hague-based court. 'This is part of Kenya respecting its legal obligations under international law.'
Kenyans hope the vote, which has so far passed off with only pockets of unrest on voting day, would restore their nation's reputation as one of Africa's most stable democracies after killings last time left more than 1,200 dead.
Many Kenyans have said they are determined to avoid a repeat of the post-2007 chaos that brought the economy to a halt.
Church leaders in Kisumu, in the west of Kenya that was devastated five years ago, sought to defuse tension this time.
Some said it was time to move on. 'I urge our candidate to forget the presidency and let the will of God prevail,' said cloth vendor Diana Ndonga.
Many shops stayed closed as a precaution in the port city of Mombasa, another Odinga stronghold, but streets were calm.
'We are heading for a bleak future where the economy goes down and international relation sour because of the ICC case,' said Athumani Yeya, 45, a teacher in the city.
Others were hopeful that Kenyatta could bring change.
'We are celebrating. Even with the ICC case in Holland, the people of Kenya still have faith in him,' said Thomas Gitau, 25, a bare-foot car washer on a main Mombasa street. 'We hope he can fix infrastructure and security so we have more jobs.'
Odinga's camp had said even before the result that they were considering a court challenge. In 2007, he said the courts could not be trusted to handle the case. Kenyatta's camp had also complained about counting delays and other aspects of the vote.
But many Kenyans said this race was more transparent. Turnout reached 86 per cent of the 14.3 million eligible voters.
Commenting on the results, the UK's Minister for Africa, Marks Simmonds, said: 'I congratulate the Kenyan people for the peaceful and determined spirit in which Monday’s elections were conducted.
'Kenyans have expressed their sovereign will, and I congratulate all the candidates who have been successful.
'This is a historic moment for Kenya, when the Kenyan people have come together at the ballot box to achieve the promise of the new constitution and choose their future leaders.
'I urge all sides to show patience and restraint, to accept defeat or take any disputes to the courts. I am confident that any disputes will be dealt with by the courts swiftly and fairly. I appeal to all parties to maintain the same peaceful and democratic spirit that we have witnessed so far.
'The UK greatly values its deep and historic partnership with Kenya, and will continue to work in support of stability, security, development and prosperity.'
Flora Bahati Lyimo: say> Nawaombeeni AMANI YA BWANA IWE NANYI MAJIRANI ZETU"