Egypt's top appeals court on Thursday acquitted Hosni Mubarak of involvement in the killing of protesters during a 2011 revolt, ending the final trial for the strongman who ruled for 30 years.
Mubarak had been sentenced to life in 2012 but an appeals court ordered a retrial, which dismissed the charges two years later.
Thursday's ruling by the Court of Cassation is final.
The trial was Mubarak's last, after prosecutors levelled various charges against him following his February 2011 resignation.
He was accused of inciting the deaths of protesters during the 18-day revolt, in which about 850 people were killed as police clashed with demonstrators.
Mubarak, 88, has spent most of his time in a military hospital since his arrest in 2011.
In January 2016, the appeals court upheld a three-year prison sentence for Mubarak and his two sons on corruption charges.
But the sentence took into account time served. Both his sons, Alaa and Gamal, were freed.
Six years after his overthrow, most of the charges brought against his regime members have been dismissed while the country still recovers from the aftermath of the uprising.
The revolt had ushered in years of instability that drove away tourists and investors, decimating the economy.
Mubarak's Islamist successor, Mohamed Morsi, served for only a year before the military ousted and detained him in 2013, launching a deadly crackdown on his supporters.
Morsi and hundreds of Islamists have been sentenced in mass trials, although many of them are appealing the verdicts.
A former air force chief and vice president, Mubarak became president after jihadists who had infiltrated the army shot dead president Anwar Sadat during a military parade in 1981, also wounding Mubarak.
He remained defiant throughout his trial.
"I did nothing wrong at all," he told a private broadcaster after receiving the life sentence in 2012 over the deaths of protesters.
"When I heard the first verdict I laughed. I said: 'Ha!'."
Apparently referring to economic growth, he said: "The last 10 years showed more results than the 20 years before, including telephones and so on, and then they turned against us."
Critics say that the abuses they fought under Mubarak have returned with President Abdel Fattah al-Sisi, the former army chief who toppled Morsi.
Morsi's overthrow sparked a jihadist insurgency that has killed hundreds of policemen and soldiers.
It has also led Sisi to argue that while he supports human rights, the dangers facing the country also require a firm hand.