Joyous celebrations erupted outside the court and in Nairobi slums after the second term victory of President Uhuru Kenyatta was declared "invalid, null and void".
Veteran opposition leader Raila Odinga, 72, for whom the court decision represented a rare victory in his political career, hailed the ruling as historic.
He said it was the first time a presidential result had been overturned in Africa.
Chief Justice David Maraga said a majority decision by the panel of seven judges, with two dissenting, found that Kenyatta "was not validly elected", rendering the result "invalid, null and void".
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".