The former president, who had been ousted in a popular revolt in 2011, was arrested and charged with multiple crimes, including embezzling funds and ordering the killing of protesters during the uprising.
But with the cases dragging on for years, and a friendly military regime taking over from the Muslim Brotherhood presidency that eventually replaced him, Mubarak's outlook took a sudden turn for the better. On Tuesday, a Cairo court ordered that he be released from pretrial detention pending the start of a new case against him.
The military-backed government announced on Wednesday night that Mubarak, who was flown Thursday to a nearby military hospital, will be held under house arrest. He also remains on a no-fly list, and his bank accounts are still frozen.
The actual course of the multiple charges against the former president is extremely complicated to track. A helpful explainer released Wednesday by the Egyptian Initiative for Personal Rights, a local human rights organization, explains that he has not yet been acquitted in any of the cases against him. Instead, Mubarak has reached the end of the period that he can legally be held in prison pending trial. In the one case that has been heard, for killing protesters, Mubarak was convicted and sentenced last year to life in prison -- but the ruling was overturned by an appeals judge.
In fact, before his release, Mubarak was not required to be held under any of the cases pending against him. His continued stay in prison seemed more a political decision than a legal one, stemming largely from procedural tricks and delays meant to prolong his pretrial term in detention.
But on Thursday, legal considerations outweighed political ones.
Outside Tora Prison, on the southern edge of Cairo, a small crowd of locals and passersby had gathered Thursday morning, most of them there to visit friends or family members in the prison. Periodically, a small chant rose up in support of the detained leader. Across the street, almost as many reporters sat watching the front gate.
In the end, Mubarak left without fanfare, as expected, flying away from the prison facility in a military helicopter just before 4 p.m. local time. His supporters cheered and waved posters bearing his face as the helicopter departed.
The release comes at a fragile time for Egyptian society, as partisans debate furiously whether the military's takeover constituted a dismantling of the gains of the revolution, or simply a restoration of it after a failed Brotherhood presidency.
"This release is all just part of the coup," 20-year-old Abdul Rahman Zenet said quietly, as he stood in line waiting for the chance to visit a family member who had been swept up in the recent Brotherhood crackdown. "I hope we can go back to the days of Jan. 25, ."
Mubarak is due back in court on Aug. 25 for the next session of his trial for allegedly ordering the killing of demonstrators in 2011.