Mr Kenyatta, in office since 2013, took 54.3% of votes, ahead of his rival Raila Odinga, with 44.7%.
After the announcement, Mr Kenyatta called for unity, telling opposition supporters: "I reach out to you... We are all citizens of the same republic".
But the opposition rejected the results even before they were declared, calling the process a "charade".
However, it has been endorsed by international observers. Mr Kenyatta said they had ensured a "free, fair and credible election".
Angry protests have started in the city of Kisumu - an opposition stronghold - and in a slum in the capital, Nairobi. Police, who were deployed in anticipation of the results, have fired tear gas.
Fires have been lit by protesters on Nyerere Road in the heart of Kisumu, a BBC reporter at the scene says.
Earlier, Mr Odinga's supporters said he had won, and published their own figures. The electoral commission said this was "illegal and premature", and said basic mathematical errors had been made.
Many observers fear a repeat of the violence after the disputed election 10 years ago, when more than 1,100 Kenyans died and 600,000 were displaced.
Raila Odinga has come up short again in what was his fourth and probably last attempt to become the president of Kenya.
The 72-year-old opposition leader had campaigned as a change candidate, calling himself the biblical Joshua and promising to lead Kenyans to Canaan, the promised land.
Despite the fact that he rallied and excited thousands across the country, a majority of voters have rejected his message, or rather rejected him, and embraced Mr Kenyatta's vision of transforming the country.
This election was also about the political duel between the Kenyatta and Odinga families, which dates back to Kenyan independence in 1963. Once again, the Kenyatta camp has won.
Ahead of the announcement of results, one of the leaders of the opposition Nasa alliance, Musalia Mudavadi, said concerns about the poll had not been adequately addressed.
Nasa has complained of fraud and hacking, but the election commission has defended its process and says the results published are accurate.
Another top opposition official, James Orengo, said the coalition would not be taking its issues to court, raising the spectre of street protests.
He hit out at international observers, including former South African President Thabo Mbeki and former US Secretary of State John Kerry, casting doubt on their credentials.
"Nobody should think this is the end of the matter," he said.
Regional leaders, including Ugandan President Yoweri Museveni and Rwandan President Paul Kagame, have congratulated Mr Kenyatta.
About Article Author