The court ordered a new election within 60 days.
The election commission had declared incumbent Uhuru Kenyatta the winner by a margin of 1.4 million votes.
His opponent, Raila Odinga, said the commission was “rotten” and demanded resignations and prosecutions.
President Uhuru Kenyatta said he would respect the court’s decision but also branded the judges “crooks”.
Other elections in Africa have been annulled or canceled but this appears to be the first time on the continent that an opposition court challenge against a presidential poll result has been successful.
Chief Justice David Maraga said the August 8 election had not been “conducted in accordance with the constitution” and declared it “invalid, null and void”.
He said the verdict was backed by four of the six Supreme Court judges.
The announcement drew cheers from opposition supporters both inside and outside the courtroom.
The court ruling did not attribute any blame to Uhuru Kenyatta’s party or campaign.
Justice David Maraga said the election commission had failed “to conduct the presidential election in a manner consistent with the dictates of the constitution”.
He said the commission had committed irregularities “in the transmission of results”, adding that the court would provide details in a full judgment within 21 days.
Dissenting judges said that the Nasa opposition alliance – which had petitioned the Supreme Court – failed to prove claims that the polls had been rigged.
The election sparked days of sporadic protests, in which at least 28 people were killed. The vote had raised fears of major political violence – as was the case after a disputed poll in 2007.
Raila Odinga, 72, said the ruling marked “a historic day for the people of Kenya and by extension for the people of the continent of Africa”.
He said: “It is now clear that the entire [electoral commission] is rotten.
“It is clear that the real election results were never shared with Kenyans. Someone must take responsibility.”
He added: “We won the elections and we are going to win them again.”
In a TV address, President Kenyatta said that it was “important to respect the rule of law even if you disagree with the Supreme Court ruling”.
He called for calm, saying: “Your neighbor will still be your neighbor, regardless of what has happened… My primary message today to every single Kenyan is peace. Let us be people of peace.”
Uhuru Kenyatta, 55, added: “We are ready to go back again to the people with the same agenda that we delivered to the people.”
The president was more combative later at a rally of supporters in a market in Nairobi.
He referred to Justice David Maraga and his fellow judges as wakora (crooks in Swahili), saying they had “decided to cancel the election”. He warned the chief justice that as the poll had been annulled he was now the president again, not president-elect.
“Do you understand me? Maraga should know that he is now dealing with the serving president,” the president said.
“We are keeping a close eye on them. But let us deal with the election first. We are not afraid.”
After the election, international monitors from the EU, the African Union and the US had said there was no major fraud on polling day and urged Raila Odinga to concede.
On September 1, Marietje Schaake, the head of the EU Observer Mission, said the court ruling represented “a historic day for Kenya and we have always said that people who feel aggrieved should seek the path of the courts”.
She said the monitors had at the time pointed to irregularities and encouraged the Kenyan authorities to deal with them.
Marietje Schaake said the monitors were awaiting the full details of the ruling.
Image source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…