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 demonstrations 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.