CAIRO -- Egypt's military-appointed government ordered former President Hosni Mubarak transferred from prison to house arrest late Wednesday after a court said he could no longer be held legally behind bars.
The order, announced by the cabinet, did not specify when the transfer would take place or where Mr. Mubarak would be moved, but said it could happen as early as Thursday. Mr. Mubarak, who ruled Egypt for 30 years, has spent the past 17 months in prison.
Mr. Mubarak's release from prison to a much milder form of incarceration injects a potentially volatile new element into the political crisis that has been convulsing the country in the six weeks since the military ousted the man who replaced Mr. Mubarak, the Muslim Brotherhood's Mohamed Morsi, Egypt's first freely elected president. Mr. Morsi remains under indefinite detention in an undisclosed location with no access to legal counsel.
The announcement regarding Mr. Mubarak came after an Egyptian court ruled that all appeals by prosecutors to keep him locked in prison had been exhausted.
An official in the office of his lawyer, Farid el-Deeb, said the firm expected that Mr. Mubarak, 85, would be released within a matter of hours.
It was unclear why the cabinet had decreed Mr. Mubarak must remain under house arrest. But under the state of emergency declared in Egypt after Mr. Morsi was deposed, the military-appointed government can exert unlimited powers in the country's easily manipulated judicial system.
Even some of Mr. Mubarak's opponents expected his release. "We are now facing a sound release order, and the prosecution will appeal and the appeal will be denied and he will walk out, and he has a right to do so," said Khaled Abu Bakr, a prominent lawyer involved in the cases of protesters killed during the protests against Mr. Mubarak that preceded his downfall more than two years ago.
Wednesday's court order applied to the last of at least three prosecutions that Mr. Mubarak still faced. He had already been ordered freed pending trial on two other cases, including a retrial on charges of complicity in the deaths of 800 protesters at the end of his regime in January 2011.
The juxtaposition of leniency for Mr. Mubarak while Mr. Morsi remains in custody could test the level of support for the military-led government among the many anti-Mubarak people who later sided with the decision to depose Mr. Morsi and crack down on the Muslim Brotherhood.
Reached by telephone and told that Mr. Mubarak's release from prison now looked imminent, Ahmed Maher, the founder of the 6th of April youth group that helped start the revolution, was initially silent for several moments. "I'm shocked," he said.
But he said he saw no likelihood of street protests because opponents of the government had been cowed into silence by widespread killings and arrests.
"If anybody even thinks of objecting, they will suffer," he said. "If anybody dares express opposition against the government or the president or the military, they'll be accused of treason and called a Muslim Brother in hiding."
In Cairo's Tahrir Square, where protesters once hung banners and nooses demanding Mr. Mubarak's execution, public opinion appeared to have moved on. No one seemed to care much about Mr. Mubarak's fate. The only ones who did appeared to be groups of Western journalists looking for reactions.
There was more concern from the Tamarod movement, the organization that ran a petition drive calling for Mr. Morsi's ouster and calling for the June 30 demonstrations that led the military to depose him.
The group blamed Mr. Morsi for not having more aggressively prosecuted Mr. Mubarak and his subordinates for the deaths of protesters.
Ahmed al-Bahrawy, a prosecutor in charge of trying of serious public corruption cases, said that his staff would not be able to appeal the release order in Mr. Mubarak's case because it had been issued at the court's appellate level already.
According to Al Ahram, the state newspaper, citing security concerns, the military moved the latest trial in Mr. Mubarak's case to the prison where he has been held, rather than forcing him to endure the spectacle of a public court hearing, as he had done in the past.
The formal decision to release Mr. Mubarak was made by the Northern Court of Appeals in Cairo in the so-called Al Ahram gifts case. Mr. Mubarak was charged with corruption for accepting a series of gifts valued at 28 million Egyptian pounds, about $4 million, from Al Ahram, the state-owned news organization.
His lawyer, Mr. Deeb, argued that he should be released pending trial because he had already made restitution for that amount to Al Ahram.
Mr. Deeb had argued that keeping Mr. Mubarak in prison, where he has languished since April 2011, was abusive and exceeded the legal limits for a prisoner awaiting trial. Chronically ill, Mr. Mubarak has been held most recently in the Tora Prison's hospital wing.
Mr. Abu Bakr said that it was routine in Egyptian legal proceedings for prosecutors to automatically appeal release orders andthat normally, courts rejected those appeals. In past months, that procedural tradition was ignored because of political pressure to keep Mr. Mubarak behind bars, he said. "What happened before when prosecutors pre-empted Mubarak's release with new charges to keep him held under Morsi is a mockery," Mr. Abu Bakr said.
Mr. Mubarak ruled Egypt with the support of the Egyptian military, until the military bowed to popular protests and removed him from office in February 2011.
His ouster, and the disgrace of a public trial in courtrooms full of opponents and television cameras, was deeply unpopular among some of Egypt's allies, particularly Saudi Arabia, which helped put together a $12 billion aid package for Egypt after Mr. Morsi was deposed last month.
The money will help offset threats to cut off aid from the United States and European countries over the huge numbers of deaths in the pro-Morsi protests, although the Egyptian military remains dependent on Washington's aid for upgrades and maintenance of its American military hardware.
Just in the past week, more than 1,100 people have been killed and hundreds of Muslim Brotherhood activists and leaders have been arrested, including their spiritual leader, Mohamed Badie.
Mr. Morsi's own arrest shortly after the military takeover July 3 was initially without formal charges, although he has subsequently been charged with having escaped from prison during the anti-Mubarak revolution. He had been jailed for protesting against Mr. Mubarak, and when the prison fell to a general revolt by prisoners, he was among many who walked out -- although he publicly announced his presence to avoid being charged with the crime of prison break.
Mr. Morsi also has been held for investigation on espionage charges. One American-trained legal expert here, speaking anonymously for fear of retaliation, called the espionage charge "self-contradictory on its face, unless one believes that someone else, such as the military, truly represents the state."
Yet unlike Mr. Mubarak, Mr. Morsi has not had access to a lawyer or visits from family members, who have no idea where he is being held.
Mr. Morsi's overthrow, and the military's imposition of martial law and announcement that it would hold a referendum on a new constitution, have generally been popular, even among many who previously opposed Mr. Mubarak's regime. That included even many of the early revolutionary groups.
"The release of Mubarak may be the chance for others to snap out of it, and understand what's really happening: the return of the old regime," Mr. Maher of the 6th of April group said. "Maybe now they will understand that we've been fooled."
David D. Kirkpatrick contributed reporting.world
This article originally appeared in The New York Times.