A prosecutor allowed Monday for Hosni Mubarak to be released, his lawyer said, after an appeals court acquitted Egypt's ex-president of involvement in the killing of protesters during the 2011 uprising.
"He can go home now when the doctors decide he is able to," Farid al-Deeb said, adding that Mubarak is banned from leaving the country pending an ongoing graft investigation.
Mubarak, 88, has spent most of his time detained at a military hospital in Cairo since his arrest in 2011.
Egypt's top appeals court on March 2 acquitted Mubarak of involvement in the killing of protesters during the revolt that toppled him, ending the final trial for the strongman who had ruled for 30 years.
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 was sentenced to life in 2012 in the case, but an appeals court ordered a retrial, which dismissed the charges two years later. His acquittal this month is final.
Amid public anger, prosecutors had levelled various charges against Mubarak following his February 2011 resignation.
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 of his sons, Alaa and Gamal, were freed.
A former air force chief and vice president, Mubarak became president after jihadists who had infiltrated the army shot dead president Anwar Sadat at a military parade in 1981, in an attack in which he was himself wounded.
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 ushered in instability that drove away tourists and investors, taking a heavy toll on the economy.
Mubarak's elected successor, Mohamed Morsi, served for only a year before the military toppled and detained him in 2013, before launching a deadly crackdown on those who backed him.
Hundreds of Morsi's supporters were sentenced to death after speedy trials. Morsi himself has also stood trial in several cases.
Morsi's overthrow sparked a jihadist insurgency that has killed hundreds of policemen and soldiers.
Critics say that the abuses they fought under Mubarak have returned with President Abdel Fattah al-Sisi, the former army chief who toppled Morsi.
It has also led Sisi to argue that while he supports human rights, the dangers facing the country also require a firm hand.