Mr Kenyatta, in office since 2013, took 54.3% of votes, ahead of his rival Raila Odinga, with 44.7%.
But the opposition coalition rejected the commission’s announcement before the results were declared, calling the process a “charade”.
International observers have described the election as free and fair.
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.