Hosni Mubarak, the Egyptian president overthrown in the 2011 revolution, is likely to be freed from detention within days.

Judicial authorities ruled on Monday that he had already spent too long in custody after one of the charges against him was dropped.

News of Mubarak's imminent release looks likely to inflame a highly volatile mood in Egypt. It comes after the army's clearance of two Cairo protest camps last week, which sparked bloodshed in which at least 900 people have been killed, and unprecedented polarisation following the military's removal of the elected Muslim Brotherhood president, Mohamed Morsi, last month.

On a day in which 26 policemen were gunned down in the Sinai peninsula, apparently by a jihadi group, and furious responses to the deaths on Sunday of 36 detained members of the Brotherhood, Mubarak's lawyer, Fareed el-Deeb, said his client would be freed after the Cairo criminal court ordered his release in one of the remaining corruption cases against him.

Mubarak and his two sons were charged with embezzling funds for presidential palaces.

"All we have left is a simple administrative procedure that should take no more than 48 hours. He should be freed by the end of the week," Deeb said. State TV reported later that Mubarak's sons Gamal and Alaa would remain in custody.

Mubarak, who is 85 and in poor health, still faces retrial on charges of complicity in the murder of protesters during what was at the time the biggest revolt of the Arab spring, so any release could be temporary.

Egyptian commentators suggested that though the move was a legal one, it would inevitably be given a political interpretation in the current circumstances.

Anger at Morsi's overthrow and the dominant role now being played by the military has led many Egyptians to conclude that the gains of the 2011 revolution have all been reversed and that the so-called "deep state" has triumphed.

If Mubarak is now freed it will have enormous symbolic significance, especially as the democratically elected though deeply unpopular Morsi shows every sign of staying behind bars and moves are afoot to crush the Brotherhood.

Mubarak ruled Egypt from October 1981, when as vice-president he succeeded Anwar Sadat following his assassination, until January 2011.