Kenya's President Uhuru Kenyatta secured a second term in office, results showed on Friday, setting off wild street celebrations by his supporters and protests in opposition strongholds in the capital and the west of the country.
Speaking after the result of Tuesday's election was announced, Kenyatta offered an olive branch to the opposition, urging national unity and peace with rivals who have rejected the result and raised the prospect of street protests.
Many Kenyans fear a repeat of the violence that followed the 2007 disputed election, when about 1 200 people were killed and hundreds of thousands displaced as protests over the result led to ethnic killings.
Kenyatta got 54.3% of the vote, ahead of rival Raila Odinga who secured 44.7%, according to election commission figures. Nearly 80% of the 19 million registered voters cast their ballots.
"To my worthy competitor Raila Odinga, I reach out to you, I reach out to your supporters, let us work together," Kenyatta, 55, said, shortly after being declared winner.
"Let us be peaceful, let us share together," he said. "Reach out to your neighbor, shake their hand. Say this election is over, let us move on."
In Nairobi and other towns in Kenya his supporters took to the streets to celebrate, honking car horns and blowing whistles.
However, there were also protests.
Police fired tear gas and gunshots were heard in the Nairobi slums of Mathare and Kawangware, where young men took to the streets as police helicopters buzzed overhead.
In Kisumu, an Odinga stronghold in the west, youths banged drums and tires burned in the streets in the Kondele district.
"A charade"
As election officials prepared the final results, the NASA opposition coalition, led by 72-year-old Odinga, who has lost the last two elections amid complaints of fraud, said it rejected the process after its complaints had not been addressed.
"We raised some very serious concerns. They have not responded to them. As NASA we shall not be party to the process they are about to make," senior opposition official Musalia Mudavadi told reporters.
James Orengo, one of Odinga's top lieutenants, said the process had been a "charade".
He stopped short of calling for protests but praised the Kenyan people's history of standing up to stolen elections and said there were "constitutional alternatives" to challenging any result.
"Going to court, for us, is not an alternative. We have been there before," he said.
"The Kenyan people have never disappointed ... every time an election has been stolen, theKenyan people have stood up to make sure changes are made to make Kenya a better place."
Earlier, Orengo had called for the candidates and observers to be given access to the election commission's computer servers so there could be a transparent audit of data from 41 000 polling stations across the country.
Yakub Guliye, election commissioner in charge of information technology, said the opposition had not made a formal request and it would not act on a verbal request.
Normal procedure calls for the commission to release final results after cross checking electronic tallies with paper forms.
Odinga's camp has said figures released by the commission since Tuesday's vote were "fictitious" and that "confidential sources" within the commission had provided figures showing Odinga had a large lead in the race.
The election commission rejected the claims, pointing out they contained basic mathematical errors.
Security
Police had beefed up security across much of Kenya - particularly in opposition strongholds in the west and parts of Nairobi - in anticipation of the announcement of the result.
Kenya is the leading economy in East Africa and any instability would be likely to ripple through the region.
Odinga is a member of the Luo, an ethnic group from the west of the country that has long said it is excluded from power. Kenyatta is from the Kikuyu group, which has supplied three of four presidents since Kenya gained independence from Britain in 1963.
International observers have given the thumbs-up to the vote and U.S. Ambassador Robert Godec issued a statement on behalf of the diplomatic community calling for any complaints to be channeled through the courts, not street protests.
"If there are disputes or disagreements, the Kenyan constitution is very clear on how they are to be addressed. Violence must never be an option," he said on Friday.
But the opposition criticized foreign observer missions, which included former South African president Thabo Mbeki and former U.S. Secretary of State John Kerry, saying they should have been "vetted" ahead of the vote.
"The observers largely served the interests of the government," Orengo said.
As well as a new president, Kenyans also elected new lawmakers and local representatives. Some of those races have also been disputed, leading to violence in Garissa and Tana River counties.
(Additional reporting by Noor Ali in Isiolo; Ed Cropley, George Obulutsa, Katharine Houreld and David Lewis in Nairobi; Writing by David Lewis and Katharine Houreld; Editing by Janet Lawrence)