In a stunning decision that reverberated across the African continent, the Kenyan Supreme Court has nullified the election victory of President Uhuru Kenyatta and ordered a new election within 60 days.

It's believed to be the first time in African history that an opposition court challenge has led to the overturning of an election result. By a 4-2 decision, the Supreme Court ruled on Friday that the election's integrity had been tainted by irregularities in the vote-tallying process.

The court ruling was praised across the world as a step forward for African democracy, but it raised awkward questions about the Western governments – including Canada – that had rushed to endorse the President's victory even while the opposition was challenging the result.

Story continues below advertisement

Foreign election observers had quickly declared the Aug. 8 voting process to be credible. The United States officially congratulated Mr. Kenyatta for his "re-election" on Aug. 14, while Canada issued similar congratulations to him two days later.

Now, in the aftermath of the Supreme Court ruling, those declarations seem premature and damaging to Kenya's democracy. Many Kenyans have criticized the foreign observers and governments for endorsing the election so swiftly.

Before its ruling, the Supreme Court heard evidence from experts who found irregularities in nearly one-third of the electoral forms on which the votes were tallied. They also found evidence of unauthorized entries to the computer server of the electoral commission. The court ruled that the commission had "failed, neglected or refused to conduct the presidential election in a manner consistent with the dictates of the constitution."

Opposition supporters celebrated wildly in the streets of Nairobi and other cities. It was a rare victory for them. A similar challenge after the 2013 election had been dismissed by the same court.

The main opposition candidate, Raila Odinga, called it "a historic day for the people of Kenya, and by extension the people of Africa." He called for criminal charges against members of the electoral commission, accusing them of fraud.

Mr. Odinga had failed in three previous bids for presidential election, and the official results said he lost to Mr. Kenyatta by 54 per cent to 44 per cent. "I am happy to be Kenyan today," he said on Friday.

Mr. Kenyatta, addressing the country on television, said he accepted the court ruling. But he also scoffed at the judges, calling them merely "six people" who had rejected "the will of the people."

Story continues below advertisement

One of his lawyers, Ahmednassir Abdullahi, denounced the ruling in inflammatory language, calling it a "very political decision" and a "judicial coup d'etat." One of his political allies, Senator Irungu Kang'ata, called it a "fake" judgment.

Some analysts expressed concern that Mr. Kenyatta could undermine Kenya's judiciary by attacking the court ahead of the new election. The campaign is expected to heighten political tensions, amid growing fears of violence.

Even before the election, there were worrying signs. A senior official of the electoral commission was kidnapped and murdered, and two foreign advisers to the main opposition party – including a Canadian – were arrested and deported just days before the election.

On Kenya's stock exchange, Friday's court ruling triggered a plunge in many stocks, and trading was halted for about half an hour.

The court's nullification of the election result "has significantly increased the likelihood of a violent crisis in East Africa's largest economy," said a commentary by John Ashbourne, Africa economist at Capital Economics.

"The new vote will be very tense," he said. "The ruling leaves the authorities with little time to improve or reform the scandal-plagued election commission, which may throw doubt on the result. Opposition supporters – whose distrust in the voting system appears to have been validated – may see another win for President Kenyatta as proof that the authorities are conspiring against them."

Story continues below advertisement

It's unclear how the new election will be financed. The last election cost about $500-million (U.S.), with hundreds of thousands of temporary election workers.

While the new election may be risky, the court ruling is being praised as a breakthrough for democracy and the rule of law in a region where vote-rigging has been common in the past.

"Today's historic ruling demonstrates the independence of Kenya's judiciary and sets an example for the rest of the world," said Justus Nyang'aya, the Kenyan director for Amnesty International.

A statement by Western ambassadors in Kenya, including the Canadian high commissioner, said the court ruling was "an important moment for Kenya." It added: "The court's independent review has demonstrated Kenya's resilient democracy and commitment to the rule of law. … All electoral processes can be improved, and we will continue to support Kenya's institutions in this important work."