Lawyers for the Kenyan opposition filed a petition with the Supreme Court challenging President Kenyatta’s re-election.
In a ruling issued on Friday, the court said the electoral board committed “irregularities and illegalities” during last month’s vote, harming the integrity of the election.
The Nairobi-based court ordered another presidential election to be held within 60 days.
“The declaration [of Kenyatta’s win] is invalid, null and void,” said Judge David Maraga, announcing the verdict of four out of the six judges.
No presidential election in Kenya has ever been nullified before.
Maraga said the election commission “failed, neglected or refused to conduct the presidential election in a manner consistent with the dictates of the constitution”.
In a national address following the court decision, Kenyatta said that while he “personally disagrees” with the ruling, he will “respect it, as much as I disagree with it”.
“It is important to respect the rule of law … we are ready to go back again to the people with the same agenda,” he said as he appealed for calm.
But he also criticised the six members of the Supreme Court for going “against the will of the people”, by nullifying the vote.
Later on Friday, Kenyatta told his supporters that his status as “president-elect” had been taken away by “Maraga and his crooks.”
He added that the judges should know they are dealing with an incumbent president.
A lawyer for Kenyatta, Ahmednasir Abdullahi, said the decision was “very political” and the election board had “done nothing wrong”. But he said the decision had to be respected.
The protest was brought before the Supreme Court by opposition leader Raila Odinga.
Kenyatta was announced the winner with 54 percent of the vote – but Odinga claimed the election was rigged with electronic voting results hacked into and manipulated in favour of Kenyatta.
Kenya’s electoral commission had said there was a hacking attempt but it had failed. International election observers said they saw no interference with the vote.
Odinga supporters erupted in jubilation after the decision was announced.
“This is an unprecedented ruling,” Odinga said outside the court. “This is a triumph for the people of Kenya.”
He condemned members of the electoral board and vowed to press for criminal proceedings.
“We have no faith at all in the electoral commission as currently constituted. They have committed criminal acts,” said Odinga.
“Most of them actually belong [in] jail and, therefore, we are going to ask for prosecution of all the electoral commission officers who have caused this monstrous crime against the people of Kenya.”
Odinga’s lawyer had asked the court to invalidate Kenyatta’s win, saying a scrutiny of the forms used to tally the votes had anomalies that affected nearly five million votes.
Odinga said the ruling sets a precedent for the African continent and he thanked the judges for acting “for posterity of Kenyans”.
Residents in the western city of Kisumu, where Odinga has strong backing, celebrated in the streets. Motorcycle riders honked their horns.
“Today is a special today and I will celebrate until I am worn out,” said 32-year-old Kevin Ouma.
East Africa’s biggest economy has a history of disputed elections. A dispute over the 2007 poll, which Odinga challenged after being declared loser, was followed by weeks of ethnic bloodshed in which more than 1,200 were killed.
Al Jazeera’s Mohammed Adow, reporting from the court in Nairobi, said Friday’s ruling was “historic, unprecedented anywhere in Africa”.
“The judges found that the electoral commission did not conduct the election according to the constitution and the electoral laws of Kenya. They say there have been massive irregularities in the transmission of the results from the polling station to the national tallying centre,” said Adow.
“This verdict given today raises a lot of questions.”
Unease around the election rose when the official who oversaw the electronic voting system was found tortured and killed days before the vote.
Security was tight around the court on Friday with armed police and barricaded streets. Human rights groups have said police killed at least 24 people in the unrest that followed the August 8 vote.
Odinga has contested the last three elections and lost each time. After each one, he has claimed the votes were marred by rigging. In 2013, the Supreme Court dismissed his petition.
This time, his team focused on proving that the process for tallying and transmitting results was flawed, rather than proving how much of the vote was rigged.