
An Egyptian court made the ruling today, as he faces separate corruption charges.
The 84 year old former leader is awaiting a retrial for conspiring to kill protesters in early 2011.
His lawyer successfully argued that he had spent the maximum time in prison under temporary detention.
The case has been referred to a different court, which is expected to appoint a new panel to hear the retrial.
About 850 people were killed in the 2011 crackdown during the 2011 uprising that ended Mr Mubarak’s rule.
He and former interior minister Habib al-Adly were sentenced to life in prison for conspiring to kill protesters.
But both will be re-tried after they successfully appealed against their convictions, with Egypt’s Court of Cassation citing procedural failings.