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.
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.
Opposition MPs in Kenya have boycotted the opening of the new parliament to protest against President Uhuru Kenyatta's decision to address it after a court annulled his election win.
They say that parliament should not have been convened until after the election re-run slated for 17 October.
The MPs instead joined opposition leader Raila Odinga for a campaign rally in the capital, Nairobi.
Mr Kenyatta said he still had the power to convene parliament.
"The set term of a president is embedded until a new one is sworn in as per the constitution," he told lawmakers.
"I want to assure every Kenyan and the world that every arm of government is in place and operational," he added.
Mr Kenyatta was declared winner of the 8 August poll, garnering 54% of the vote against Mr Odinga's 44%.
Mr Kenyatta had dared opposition MPs to skip the opening of parliament saying that his Jubilee Party had enough MPs to carry on with parliament's activities.
Only one MP from the opposition was present, according to Kenya's privately-owned Star newspaper.
The Standard publication reports that Supreme Court judges, who traditionally attend the official opening of parliament, were absent.
Chief Justice David Maraga's office however told the BBC that the judges had not been invited.
The judges are expected to make public their written judgment explaining why they annulled Mr Kenyatta's win before the end of next week.
A majority of the six judges who listened to the election petition ruled that there had been some "irregularities and illegalities" in the election.
Mr Kenyatta, who has been critical of the judges, said in his parliamentary speech that their decision had overturned the voters' will.
He also repeated his strong disapproval of the ruling but said he respects it.
He said that he had a track record of respecting the justice system: "I have previously demonstrated this before, when I conceded defeat in 2002 and heeded summons from an international court [ICC ] when I knew I was facing trumped up charges."
His initial reaction to the 1 September ruling was however scathing, with him calling the Chief Justice and his five colleagues " thugs" and promising to "fix" the court after the re-run election.
He was widely condemned for the comments but he has maintained that he has a right to criticise the court.
Meanwhile, Mr Odinga repeated his threat to boycott the election re-run unless some officials of the Independent Electoral and Boundaries Commission ( IEBC), which is in charge of elections, are fired.
He accuses them of deliberately interfering with the electoral systems to favour Mr Kenyatta.
IEBC chairman Wafula Chebukati told a press briefing on Tuesday that the commission was reviewing its structures to ensure that it is ready for the re-run election.
Kenya's opposition leader Raila Odinga has said that he will not take part in the presidential election re-run slated for 17 October "without legal and constitutional guarantees".
Last week, the Supreme Court annulled August's election result saying the electoral commission (IEBC) had not followed the constitution.
Incumbent President Uhuru Kenyatta was declared the winner by the IEBC.
The court said a new election needs to be held by 31 October.
Speaking to journalists, Mr Odinga said that the fresh vote must held in an environment where everything that went wrong can be corrected.
"We know exactly what transpired in these last elections, we know what the IEBC did and we know that if we were to go back there will be no different results and that's why will say there will be no elections on the 17 October," he said.
Mr Odinga's opposition Nasa alliance went to the Supreme Court to challenge President Kenyatta's win arguing that the results had been tampered with during transmission from the polling stations.
They alleged that someone gained access to the IEBC's computer servers to tweak the results in favour of Mr Kenyatta.
The court found that, among other things, the IEBC had committed "illegalities" in the transmission of results. But as it has not released its full ruling it is still not clear exactly what went wrong.
The Supreme Court said on Friday that it would make its full ruling public within 21 days.
Mr Odinga wants the IEBC to strictly follow the constitution's guidance on conducting elections.
He also wants some of the commissioners to be sacked, alleging that they are partisan, and he is pushing for access to IEBC's electronic voting and result transmission system.
Mr Odinga criticised the IEBC for announcing the new election date saying that opposition parties had not been consulted.
Nasa sent a letter to the IEBC arguing that the date for the fresh election "should be a product of consultation with concerned parties and not a unilateral decision".
The opposition leader alleged that the election date was set by the governing Jubilee Party.
Mr Odinga also faulted the IEBC for saying that the new election will just be between him and Mr Kenyatta. There were eight candidates on the ballot paper in August.
"The entire election was cancelled by the Supreme Court," he said. "So it means that you do a repeat of the presidential elections afresh."
For his part, President Kenyatta said last Friday that while he respected the court's annulment of the election he disagreed with the decision.
Speaking to supporters later that day, at an impromptu rally in the capital, Nairobi, he described Chief Justice David Maraga as a "crook". On Saturday he vowed to "fix" the Supreme Court if he was re-elected.
Kenya's presidential election will be re-run on 17 October after the original result was annulled, the chair of Kenya's electoral body has announced.
Wafula Chekubati also confirmed that only President Uhuru Kenyatta and opposition leader Raila Odinga would be on the new ballot.
Mr Kenyatta had been declared the winner of last month's vote.
But Mr Odinga complained of widespread irregularities and the Supreme Court declared the first poll void.
The decision is the first time in African history that a supreme court has upheld an opposition challenge in a presidential election and ordered a re-run.
In a ruling on Friday, Chief Justice David Maraga said the 8 August election, in which Mr Kenyatta won 54% of the vote, had not been conducted in accordance with the constitution, declaring it "invalid, null and void".
They said that some members of the Independent Electoral and Boundaries Commission (IEBC) had committed "irregularities and illegalities" in the transmission of results.
The court ordered a new poll to be held within 60 days.
The opposition demanded that some IEBC officials be removed to ensure that the problems are not repeated in the second ballot.
In the shock verdict, the court said it would give further details about the decision within 21 days.
IEBC chair Wafula Chebukati said it was "imperative that a detailed judgement... is released in order to allow the commission to identify areas that require improvement".
After the Supreme Court's decision Mr Odinga called the electoral commission "rotten" and called for its members to resign and face prosecution.
He hailed the decision as a "a historic day for the people of Kenya and by extension for the people of the continent of Africa".
It is the third time Mr Odinga has disputed national election results, having also lost against the sitting president in 2007 and 2013.
Mr Kenyatta initially called for calm after the decision in a television address, but later referred to the judges as wakora (meaning crooks in Swahili), saying they had "decided to cancel the election".
The decision to only include Mr Kenyatta and Mr Odinga on the ballot has been controversial, with at least one of the six other candidates threatening legal action over their exclusion.
The poll had raised fears of major violence similar to that following a disputed vote in 2007, when post-election violence left 1,200 people dead.
Although the unrest after this year's vote was not as serious as that in 2007, days of sporadic protests left at least 28 people dead.
The president of Kenya, Uhuru Kenyatta, has said his country has "a problem" with its judiciary after the Supreme Court cancelled his victory in last month's presidential election.
Speaking on live television, he vowed to "fix" the court if re-elected.
It comes a day after the Supreme Court cited irregularities in the vote and ordered a new one within 60 days.
Mr Kenyatta has said he will respect the ruling and called for calm amid fears of unrest.
But at a rally in Nairobi on Friday he branded the Supreme Court judges “crooks”.
The 8 August poll raised fears of major violence similar to that following a disputed vote in 2007.
Deputy President William Ruto has called on the electoral commission to set a date for fresh presidential elections, saying the governing Jubilee Party is ready.
But opposition candidate Raila Odinga wants the commission replaced, saying it has lost credibility.
It is believed to be the first time in Africa that a court has ruled against the electoral win of an incumbent based on a court challenge by the opposition.
"We shall revisit this thing. We clearly have a problem," Mr Kenyatta said of the judiciary during his television address on Saturday.
"Who even elected you? Were you? We have a problem and we must fix it."
Although the unrest in this year's vote was not as serious as in 2007, days of sporadic protests left at least 28 people dead.
Kenya's election commission had declared Mr Kenyatta the winner by a margin of 1.4 million votes but the result was immediately challenged in court by his nearest rival, Mr Odinga.
In a ruling on Friday, Chief Justice David Maraga said the 8 August election had not been conducted in accordance with the constitution, declaring it "invalid, null and void".
The ruling did not attribute any blame to President Kenyatta's party or campaign.
Mr Odinga, 72, said the ruling marked "a historic day for the people of Kenya and by extension for the people of the continent of Africa".
Following the election, international monitors from the EU, the African Union and the US had said there was no major fraud and urged Mr Odinga to concede.