Kenya's Supreme Court has blamed the country's electoral commission (IEBC) for its decision to annul the re-election of President Uhuru Kenyatta.
The judges said the 8 August poll was "neither transparent or verifiable".
Deputy Chief Justice Philomena Mwilu said the IEBC did not verify the presidential results before they were announced.
Mr Kenyatta got 54% of the vote against opposition leader Raila Odinga's 44%, according to the IEBC's results.
Mr Odinga went to court alleging that he had been cheated of victory and that the IEBC had not followed the law in the conduct of the election.
The Supreme Court took the unprecedented step of annulling the election on 1 September but it has only now explained why it took that decision.
It was the first time in Africa that a court had agreed with an opposition demand to cancel a presidential election over rigging allegations.
While the judgement was being read out, police fired tear gas outside the Supreme Court to disperse opposition supporters who had gathered to support Mr Odinga.
At one point a swarm of bees attacked some of them.
Opposition supporters allege that the IEBC tampered with its server to fix Mr Kenyatta's win
Police fired tear gas to disperse opposition supporters
Was the election hacked?
Ms Mwilu said that the commission had not complied with a court order to allow its electronic voting system to be scrutinised.
She said that the IEBC's refusal to comply with the order to grant access to its electronic voting system led the court to "accept claims by the opposition that the computer system had been infiltrated and compromised and the data interfered with, or that the IEBC officials interfered with the system themselves".
The electoral commission has disputed that its system was tampered with.
Opposition coalition Nasa has been pushing for the sacking of IEBC officials whom it blames for bungling the polls, saying that a new team should be in charge of the re-run scheduled for 17 October.
Doubts have however been cast on this date because OT-Morpho, the French company that provided the voting kits, has said that it needs to reconfigure the more than 40,000 kits and that the process would not be complete until at least the end of October.
The judges had ordered the re-run to be held in 60 days.
Four judges voted to annul the election while two dissented. Another judge was taken ill during the hearing of the petition and did not take part in the case.
Have your say
More World Headlines
- 10 students die in suspected arson at Ugandan boarding school
- CNN sues Trump, top White House aides for barring Acosta
- California wildfires: Death toll reaches grim milestone
- Final school hostages freed in Cameroon
- Raging Californian fires kill 25
- Study finds 'huge' fall in FGM rates among African girls
- Trump, Macron may clash on European defense in Paris talks
- Death toll from Somalia hotel attack rises to 39
- Michelle Obama: I'll never forgive Trump for putting my family in danger
- 'Don't go back to school' kidnappers told freed Cameroonian students
- US proposes rule banning asylum for illegal migrants
- Ethiopia police find mass grave of 200 people
- At least 12 killed at California bar shooting
- Hundreds of buffaloes drown 'fleeing lions'
- Prince Charles wades into Jollof wars