Egypt’s prime minister ordered Wednesday that deposed autocrat Hosni Mubarak be placed under house arrest after he’s released from prison following more than two years in detention.

The announcement came hours after a court ordered Mubarak be released for the first time since he was first detained in April 2011, a move threatening to further stoke tension in a deeply divided Egypt. Many feared Mubarak’s release would amplify Islamist allegations that last month’s military coup was a step toward restoring the old regime.

Prime Minister Hazem el-Beblawi said in a statement that he ordered Mubarak be put under house arrest as part of the emergency measures put in place this month. The decision appeared designed to ease some of the criticism about Mubarak being freed from prison and ensure he appears in court next week for a separate trial.

Prison officials said Mubarak may be released as early as today. It is not clear where Mubarak will be held under house arrest, whether in one of his residences or in a hospital considering his frail health. Since his ouster, Mubarak’s supporters have released conflicting details about his health, including that the 85 year old suffered a stroke, a heart attack and at times went into a coma. His critics called these an attempt to gain public sympathy and court leniency.

His wife, Suzanne, has been living in Cairo and keeping a low-profile, occasionally visiting Mubarak and their two sons in prison. But security officials said Mubarak was more likely to be moved to a military hospital because of his ailing health.

The order for Mubarak’s release came after an appeal by his lawyers in one of his corruption cases. He is also on trial on charges of complicity in the killing of protesters in the 2011 uprising against him that could put him back behind bars. He faces investigation into at least two other corruption cases as well.

The prospect of Mubarak being freed, even if only temporarily, would feed into the larger crisis bedeviling Egypt: the violent fallout from the July 3 coup that unseated President Mohammed Morsi, an Islamist who became Egypt’s first freely elected president after Mubarak’s ouster.

Mubarak’s release “will cause chaos,” human rights lawyer Nasser Amin said. “It will be used by Islamists as proof of the return of the old regime … and can lead to new alliances between revolutionary groups and political Islam.”

El-Beblawi’s decision followed an appeal from the youth campaign that spearheaded the petition and protests against Morsi to the interim authorities to use the emergency measures in place earlier this month to keep the former president behind bars.

The group Tamarod blamed Morsi’s government for Mubarak’s coming release because they said it failed to admit new evidence in the case against the autocrat.

In a statement, Tamarod warned against releasing Mubarak, saying it would be a threat to national security. The group said revolutionary groups “will not stand idle seeing the killers of martyrs get acquitted.”

“If it is acquittal for Mubarak today, it will be acquittal for Morsi tomorrow,” the group said, vowing to hold a public show trial for Mubarak. “We will not remain silent about freedom for any killer of the Egyptian people.”

The three judges who ordered Mubarak be freed met in Tora prison, where he has been held for most of his detention since April 2011. But even before they ruled, human rights advocates have argued for a new system of justice to make up for a shoddy prosecution and a judiciary divided between loyalists of the old regime, Islamists and independents.