In a decision hailed as the first of its kind for Africa, Kenya's Supreme Court on Friday annulled the president's Aug. 8 reelection victory, citing irregularities, and ordered a new vote within 60 days.

The reversal of President Uhuru Kenyatta's win stunned this country, East Africa's economic powerhouse and a key U.S. ally in a fragile region. Analysts said it highlighted the growing independence of the courts, a major advance in a country that was effectively a single-party state until 1992. Some called the ruling a potential turning point for a nation where disputed elections have led to thousands of deaths in past years.

The 4-to-2 court ruling came in response to a petition filed by challenger Raila Odinga, 72, who alleged widespread fraud in the election.

Following the judgment, people in the court broke into cheers, with Odinga raising his fists in the air in celebration.

"This is indeed a very historic day for the people of Kenya and by extension to the people of the continent of Africa," he said outside the courthouse. "For the first time in the history of African democratization, a ruling has been made by a court nullifying irregular election of a president."

[Polls closed, then the challenges began]

For his part, Kenyatta pledged to respect the court's decision — but later assailed the judges. "They have been paid by white people and other trash," he told supporters, adding that his party would watch the court's actions. "Let's move on," he said. "But they will know we are also men."

His comments raised concerns that there could be fresh violence if he does not win the new election. Kenyatta is the scion of one of the country's most powerful political families; his father, Jomo, was a leader of the anti-colonial struggle that led to Kenya's independence from Britain in 1963. Jomo Ken­yatta became the country's first president after independence, and Uhuru Kenyatta is only its fourth.

It is rare for a court in any country to throw out the results of a presidential election. But the ruling was particularly striking on a continent notorious for fraudulent and manipulated electoral processes. Just last month, Rwandan President Paul Kagame got nearly 99 percent of the vote in an election criticized as unfair by the United States.

In Kenya, Chief Justice David Maraga described the results of last month's election as "invalid, null and void." He promised to issue full details of the ruling later.

"Taking the totality of the entire evidence, we are satisfied that the elections were not conducted in accordance to the dictates of the constitution," he said.

The court decision came as a shock to many Kenyans and foreigners alike. International observers, including former U.S. secretary of state John F. Kerry, had said last month that the balloting appeared to be free and fair.

But the opposition presented evidence of numerous anomalies in the process of counting the votes and transmitting the totals to the regional and national electoral offices. Odinga's lawyer said that some of the forms submitted with results lacked key security features such as watermarks and the necessary stamps and signatures, raising questions about their validity.

Tina Alai, a Kenyan expert in constitutional and human rights law, said the court ruling was significant in that it was not based on whether the irregularities were enough to change the result of the election. Instead, it focused on whether the electoral procedures met the constitution's requirements to be accurate, verifiable and transparent.

"What the court made very clear today is that the constitution matters, the rule of law matters, the process of arriving at an election decision matters," said Alai, who heads the Kenyan office of Physicians for Human Rights.

That is particularly important because of the country's recent history of contested elections. Kenya is vastly more stable than war-torn neighbors Somalia and South Sudan. But it remains riven by tribal rivalries that come to a head at election time, largely between Kenyatta's Kikuyu tribe and Odinga's Luo community.

After Odinga lost in the 2007 election, the country was engulfed by a wave of ethnic violence that killed 1,400 people.

"The consequences of a contested election have been so frightening for us as citizens," Alai said. If Kenyans in the future can be confident that elections are transparent, she said, there "will cease to be the opportunity where politicians can prey on these divisions among us."

In many parts of the country, Odinga's supporters were celebrating the court ruling Friday. In Nairobi's sprawling Kibera slum, where six people died in clashes following the election, residents danced holding Odinga posters.

In coastal Mombasa, people rode motorcycles through the city cheering.

According to Murithi Mutiga, a senior analyst with the International Crisis Group, the decision is unprecedented for the continent.

"I think this is an in­cred­ibly important moment for democracy for Africa," he said.

Mutiga noted that the judiciary had not always been so independent in Kenya but that under a new constitution adopted in 2010, magistrates are more insulated from pressure tactics of the executive branch.

Kenya's high court also showed its independence this year when it overruled a government decision to shut the Dadaab refu­gee camp, one of the world's largest.

[Two friends were stuck in a Kenyan refu­gee camp. A scholarship competition was their only way out.]

Odinga also had appealed to the court after losing the last presidential race, in 2013 — and dismissed it as inept after it ruled against him.

On Friday, he said that the members of the election commission overseeing the vote should face criminal prosecution. Wafula Chebukati, head of the commission, promised to make changes to personnel and processes.

The court's decision did not quell fears of political violence. At least 24 people died in clashes after the election results were announced in August.

The country's business community, which backed Kenyatta's pro-business platform, was shocked by the result, with trading briefly halted on the Nairobi stock exchange after shares plummeted. The national currency dropped in value, as well.

In his campaign, Odinga appealed to the country's less fortunate, promising greater social justice and a fight against corruption.

His lawyer had alleged that some 5 million votes were marred by discrepancies. Electoral officials had said that Kenyatta won by 1.4 million votes out of around 15 million cast.

Schemm reported from Addis Ababa, Ethi­o­pia. Kevin Sieff in Athens contributed to this report.

Read more:

Kenya’s opposition leader vows court challenge over election loss

At least 24 reportedly killed in Kenya post-election violence

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news