Kenya's deputy prime minister Uhuru Kenyatta has been confirmed as the winner of the country's presidential election.
Officials say Mr Kenyatta won 50.07% of the vote, narrowly avoiding a run-off ballot, but his main challenger alleged fraud and said he would go to court over the result.
After the results were announced Mr Kenyatta gave a victory speech in Nairobi, telling the audience he wanted to work with his opponents in moving the country forward.
He told cheering supporters at the Catholic University he would serve all Kenyans "without fear or favour".
However main rival, Raila Odinga, said there was evidence of rampant illegality in the voting process and that he would challenge the result in the Supreme Court.
Mr Odinga, the current prime minister, said the electoral commission had failed Kenyans and that democracy itself was on trial.
Mr Kenyatta is set to face trial at the International Criminal Court in The Hague for alleged crimes against humanity over violence that followed the 2007 polls, the BBC reports.
He is accused of fuelling the communal violence that saw more than 1,000 people killed and 600,000 forced from their homes. Mr Kenyatta's running mate William Ruto faces similar charges and both men deny the accusations.
The Independent Electoral and Boundaries Commission (IEBC) said the latest elections had been complex, but also credible and transparent. It said the turnout, at 86%, was the largest ever.
A new electronic system for transmitting vote results was designed to eliminate the risk of fraud 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.
Mr Odinga's Cord alliance had earlier complained that votes from 11 constituencies were missing, in effect leaving him more than 250,000 votes short.