Deputy President William Ruto has been declared the winner of Kenya's presidential election amid dramatic scenes.
He narrowly beat his rival, Raila Odinga, taking 50.5% of the vote, according to the official results.
The announcement was delayed amid scuffles and allegations of vote-rigging by Mr Odinga's campaign.
Four of the seven members of the electoral commission refused to endorse the result, saying it was "opaque".
"We cannot take ownership of the result that is going to be announced because of the opaque nature of this last phase of the general election," said Juliana Cherera, the vice-chairperson of Independent Electoral and Boundaries Commission (IEBC).
"We are going to give a comprehensive statement... and again we urge Kenyans to keep calm," she added.
Mr Odinga's party agent earlier alleged that there were "irregularities" and "mismanagement" in the election.
This was the first time Mr Ruto, 55, had run for president. He has served as deputy president for 10 years, but fell out with President Uhuru Kenyatta, who backed Mr Odinga to succeed him.
The 77-year-old former prime minister, who got 48.8% of the vote, was running for president for the fifth time.
Electoral commission chairman Wafula Chebukati said he had done his duty despite receiving threats.
"We have walked the journey of ensuring that Kenyans get a free, fair and credible election. It has not been an easy journey - right now two of my commissioners and the CEO are injured," he said.
In his speech, President-elect Ruto thanked the electoral commission for overseeing the election.
"It is a wonderful evening… all sovereign power belongs to the people of Kenya," Mr Ruto said, calling Mr Chebukati a "hero" and dismissing the other commissioners' dissent of his win as "a side show".
Mr Ruto said he wanted to be a president of all, and for the country to focus on the future.
"To those who have done many things against us, I want to tell them there's nothing to fear. There will be no vengeance. We do not have the luxury to look back," he added.
Celebrations have broken out in several parts of the country, including in Mr Ruto's strongholds of the Rift Valley, and that of his deputy Rigathi Gachagua, in the Central region.
Supporters of Mr Odinga have staged protests in the western city of Kisumu and some parts of Nairobi.
But generally there's a sense of relief that the result has finally been declared because the country had ground into a halt since election day on 9 August, economic activities had stalled and schools remain closed.
Kenya's history of disputed elections in the past have led to violence or the whole process election being cancelled.
Following the 2007 vote, at least 1,200 people were killed and 600,000 fled their homes following claims of a stolen election.
Hustler vs dynasty
In a country fond of political metaphors, Mr Ruto's stunning victory is akin to his party's modest symbol, the wheelbarrow, running a seven-tonne tractor off the road. Mr Odinga had the backing of the state machinery. Several opinion polls, which Mr Ruto had dismissed as fake, predicted his rival would win.
As the deputy president for the last 10 years he was, by default, an establishment candidate but he ran as an outsider, framing the election as between "hustlers" - poor Kenyans - and "dynasties" - influential families like the Kenyattas and Odingas who have been big players in the country's politics since independence.
"I may be the son of a nobody but I promise to make Kenya the country of everybody," he said in his pitch to voters.
His political stock rose when he opposed an unpopular and costly year-long push by Mr Kenyatta and Mr Odinga to change the constitution at a time many Kenyans were suffering, including losing jobs, following the protracted impact of the Covid-19 pandemic.
The Supreme Court eventually ruled the move unconstitutional, buoying Mr Ruto's campaign.
He also framed the election as a time for generational change, selling his message using pithy and relatable slogans, which lent him credibility and appeal across several communities.
Mr Ruto's win is rightly the focus of Kenya's 2022 election, but equal attention should be given to the electoral commission which came into this poll with a terrible track record, but its decision to post results from the more than 46,000 polling stations on its website - accessible to anyone who wanted to do their own tally - allowed the media and the public to be part of the process.
The leaders of Zimbabwe, Ethiopia and Somalia have congratulated Mr Ruto.
Analysts believe that Mr Odinga is likely to challenge the result.
The Kenyan Supreme Court annulled the last election - it might have to make another big decision in a few weeks.