Kenya's Supreme Court annulled the result of last month's presidential election and ordered a new one within 60 days.
The ruling, citing irregularities, makes Kenya the first African country to invalidate a presidential poll.
The election commission had declared incumbent Uhuru Kenyatta the winner by a margin of 1.4 million votes.
But the opposition argued that the commission's IT system had been hacked to manipulate the results.
After the ruling was announced, opposition presidential candidate Raila Odinga said: "This is a historic day for the people of Kenya and by extension for the people of the continent of Africa."
Reading the decision - reached by a majority of four to two among the judges - Chief Justice David Maraga said the 8 August poll had not been "conducted in accordance with the constitution".
Opposition supporters were seen celebrating outside the court building, as well as in opposition strongholds.
The election sparked days of sporadic protests in which at least 28 people were killed.
The vote raised fears of major political violence - as was the case after a disputed election in 2007.
Source: News Agencies, Edited by website team