The criminal court in Cairo decided to release the 85-year-old leader pending further investigation of corruption charges against him.
The ruling does not mean Mr. Mubarak will be immediately released. He will remain in prison for at least 48 hours pending a possible appeal by prosecutors, judicial sources were quoted as saying by Al Jazeera.
It also does not mean Mr. Mubarak has been acquitted on charges of taking about USD 11 million worth of gifts from Al-Ahram, the state-run newspaper.
But it removes the final legal hurdle blocking his release.
Mr. Mubarak is also facing retrial in connection with charges of killing protesters during the 2011 revolution.
He was sentenced to life in prison last year, but a retrial was ordered earlier this year. His next court hearing is scheduled for August 25.
That re-trial is still underway.
However, the case does not require Mr. Mubarak to remain in custody, as his lawyer successfully argued that the former leader has already spent the maximum time in prison for a defendant in pre-trial detention.
If Mr. Mubarak is freed later this week, it would come only six weeks after the armed forces that he once commanded deposed his freely elected successor, Muslim Brotherhood’s Mohamed Morsy.
Mr. Morsy remains in custody since the army toppled him on July 3, but his supporters have held protests calling for his reinstatement.
The court convened at Tora prison in Cairo where the ousted leader is being held, judicial sources said.
On Monday, the court had ordered Mr. Mubarak’s release pending a probe into a separate case in which he is accused of splurging 1.1 billion pounds in public funds to renovate his palatial private residences, drawing him closer to release as the number of charges he faces decrease.
The ex-president, who ruled Egypt for nearly 30 years was ousted in the 2011 Egyptian Revolution and detained shortly after, remains in prison pending investigations.