Q&A: Kenya's vote count
Uhuru Kenyatta has won Kenya's presidential election, according to official results, with 50.07% of the vote.
The count gave Mr Kenyatta 6,173,433 votes out of a total of 12,330,028, well ahead of Prime Minister Raila Odinga, who polled 5,340,546.
Mr Kenyatta's total means he will not have to face a run-off.
However, both candidates have complained of irregularities and an aide for Mr Odinga said the candidate would file a legal challenge.
Tensions following the last election in 2007 led to violence that saw more than 1,000 people killed and 600,000 forced from their homes.
Mr Kenyatta is due to stand trial at the International Criminal Court in July over his alleged role in that violence.
The latest elections were held under a new constitution designed to avoid a repeat of the bloodshed but this means some of the election rules have changed - one reason for the confusion.
Why was the result delayed?
An electronic counting system - used by Kenya for the first time in an election - broke down on Tuesday evening.
This did not surprise Commonwealth observer mission head Festus Mogae, the ex-President of Botswana, who said: "We are not yet as proficient as western Europe or North America."
It is not clear what caused the breakdown, but Kenya's deputy election commission chair Lilian Mahirie said hacking could not be ruled out.
Votes were also tallied manually, as required by law.
The election commission has by law until 11 March to confirm the final result.
This comes on top of the failure of the much-hyped multi-million dollar biometric voter registration system in many areas on Monday - the paper voters' roll was used instead.
Why is this poll disputed?
One of the main issues has been the huge numbers of "rejected" votes, which was more than the number of votes obtained by third-placed candidate Musailia Mudavadi.
On Tuesday evening, there were about 300,000 - about 6% of total votes cast.
This led to a row about whether or not they should be regarded as a "cast" ballot.
Mr Odinga's camp wanted them to be counted, but Mr Kenyatta's team opposed this.
Mr Kenyatta's running mate William Ruto has argued that "casting a vote means delivering a valid ballot paper in the right box", while a senior official in Mr Odinga's election team, Franklin Bett, has said that any vote placed in a ballot box "must be part of all the votes cast".
Election in numbers
- 14 million registered voters
- About 70% turn-out
- Eight presidential candidates
- First election under new constitution
- Winning presidential candidates need 50% of vote + 25% in half of 47 counties
- Voters got ballot papers for 6 different elections
Analyst Aly Verjee says that under the new constitution, votes do not have to be "valid" to be counted as "cast" - unlike under previous rules.
However, Kenya's election chief Issack Hassan has now said that a software bug meant that the numbers of rejected votes was multiplied by eight.
When the votes were tallied by hand, the number of rejected ballots came down to about 1% of the total.
This means Kenyans have coped pretty well with a complex poll, which, for the first time, includes six elections.
There were different ballot boxes and papers - all colour-coded - for each poll: For the president; constituency members of parliament; senators, county governors; members of the newly formed county assemblies and women's representatives.
There has also been confusion about the difference between a rejected and a spoiled ballot paper.
In terms of the law, a vote is rejected if, among other things, it does not bear the necessary security features or is "written or marked such that it is uncertain for whom the vote has been cast".
In contrast, a spoiled ballot is one that a voter "inadvertently messes up as they place a mark against the candidates". In this case, the voter can ask for another ballot and the "messed up" one is set aside as a spoiled ballot.
How did the delay go down in Kenya?
As the delay continued, greater anxiety grew among Kenyans that results could be disputed, possibly leading to violent protests.
On Thursday, Mr Odinga's running mate, Kalonzo Muzyoka, said results had been "doctored" - charges rejected by the head of Kenya's electoral body.
A day earlier, Mr Kenyatta's Jubilee coalition accused the UK - the former colonial power - of playing a "shadowy" role to deny him victory.
The UK government denied the allegation.
Mr Kenyatta's candidature has been controversial as the International Criminal Court has charged him with orchestrating violence that broke out after the disputed 2007 election.
Before the election, the European Union said it would have limited contact with a president indicted by the ICC, while US Assistant Secretary of State Johnnie Carson warned Kenyan voters that "choices have consequences".
How significant is Kenya internationally?
It is East Africa's biggest economy, and a major recipient of Western aid.
It also has the most powerful army in the region and has sent thousands of troops, with Western logistical help, into Somalia to tackle militant Islamists there.
So, the EU and US would find themselves in a politically awkward situation if Mr Kenyatta, who is due to go on trial in July, is elected president.
Within Africa, his election might be less controversial - the African Union (AU) stood by Sudan's President Omar el-Bashir after he was indicted by the ICC, arguing that he enjoyed presidential immunity and could not be put on trial.
African leaders have accused the ICC of being biased against the continent and ignoring atrocities committed elsewhere.