(AFP) - Kenya's Supreme Court on Friday ordered a new presidential election within 60 days, in a shock ruling cancelling the results of last month's poll over widespread irregularities.

Chief Justice David Maraga said a majority decision by the panel of six judges, with two dissenting, found that President Uhuru Kenyatta "was not validly elected", rendering the result "invalid, null and void".

Supporters of veteran opposition leader Raila Odinga's wept and cheered, utterly stunned at what they saw as a historic ruling, after losses in successive polls they believe were rigged, from a judiciary long seen as compromised in favour of the ruling elite.

Odinga, 72, hailed the "historic" ruling which is a first in Africa.

"It is now clear that no one in Kenya is above the law," he said.

Maraga said the election commission (IEBC) had "failed, neglected or refused to conduct the presidential election in a manner consistent with the dictates of the constitution".

Kenyatta, the first African president to have his re-election overturned by a court ruling, cheerfully took to the streets to address supporters saying he was ready to campaign again.

He slammed Maraga and his fellow judges as "crooks" as he spoke off the cuff, after earlier saying that while he disagreed with the ruling, he respected it.

- 'Kudos to the judges!' -

Kenya has a long history of disputed votes, election violence and a lack of faith in the judiciary's independence.

"It was a surprise because the trend in justice in Kenya is not good, but this time justice has been done," said 39-year-old accountancy student Donna Abongo.

"Kudos to the judges!"

"For the first time we have got justice. They have stolen elections for so long," said fishmonger Lynette Akello in western Kisumu.

The run-up to the August 8 election was marred by the murder of top IEBC IT official Chris Msando and opposition allegations that rigging was certain.

Indeed Odinga and his National Super Alliance (NASA) cried foul shortly after counting began, claiming the system transmitting votes had been hacked, and that forms from polling stations that were meant to back up the electronic results were not being uploaded.

The August 11 declaration of Kenyatta's victory with 54.27 percent of the vote -- with not all the tallying forms in -- sparked two days of protests in the slums of Nairobi and Kisumu, traditional opposition strongholds.

At least 21 people, including a baby and a nine-year-old girl, were killed, mostly by police, according to an AFP tally.

- 'Irregularities and illegalities' -

It was the third time in a row that Odinga claimed he had been cheated out of victory at the polls, after his losses in 2007 and 2013.

However, the protests remained isolated and did not reach the levels of the disputed 2007 election which saw politically-motivated ethnic violence in which over 1,100 people were killed.

In 2013, Odinga took his grievances to court and lost.

This time he initially refused to take the case to court but changed his mind, saying NASA wanted the truth to come out even if they believed they had no hope of winning.

However, in a dramatic and unexpected turn of events, the Supreme Court agreed with the opposition coalition.

Maraga said there had been "irregularities and illegalities", notably in the transmission of election results.

He said this had compromised the "integrity of the entire presidential election".

The court's full ruling must be made available within 21 days.

- Election commission vows change -

Odinga said he no longer had faith in the current election commission and called for them to step down.

But IEBC chairman Wafula Chebukati refused to resign, saying he had not been implicated in any wrongdoing personally, but vowed "internal changes to our personnel".

He called for those guilty of wrongdoing to be prosecuted.

NASA official and lawyer, James Orengo, had argued that irregularities -- including unsigned and fake tally forms, hacked servers and deliberate miscounting -- had affected around one-third of the 15.5 million votes cast.

But lawyers for the election commission and Kenyatta countered that errors were simply "clerical" mistakes and technicalities that did not affect the outcome of the vote.

A report filed by the court registrar found a number of errors in the 41,451 polling station tally sheets -- known as form 34A -- as well as in 291 of the form 34B constituency tally sheets, some of which were unsigned, not stamped, illegible or lacking serial numbers or watermarks.

In addition, the registrar's report found that the electoral commission failed to provide full court-ordered access to its servers, which NASA had demanded in order to back up its allegations of hacking.