By Tom Perry
CAIRO (Reuters) - An Egyptian court ordered the release of former prime minister Ahmed Nazif on Thursday, because of a limit on pretrial detention in a corruption case for which he had been held since the revolution that toppled Hosni Mubarak.
The court accepted an appeal lodged by Nazif, who was prime minister from 2004 until Mubarak replaced him during the uprising in January 2011. He still faces retrial in the case.
A lawyer for Nazif, Mohamed Salah al-Buheiri, said he expected his client to leave prison by Saturday at the latest after two years and two months in detention.
He will be the highest profile Mubarak-era official to be freed in recent months and the court's move comes as opponents of Islamist President Mohamed Mursi prepare mass demonstrations on June 30 to mark the first anniversary of his taking office.
Mubarak himself, a general who ruled for 30 years, remains in jail, being retried for conspiracy to murder.
Nazif, 60, was sentenced to three years in September for the unlawful possession of property and for making illegal profits from a public-interest company. Prosecutors accused him of making some $10 million from corrupt dealings. But that conviction was overturned in February and a retrial ordered.
As protesters swarmed Cairo's Tahrir Square demanding change, Mubarak fired Nazif - a close associate of the president's son Gamal Mubarak in a program of liberal economic reforms - in a move intended to appease public opinion.
"The court ruled that he be released all the while he is not wanted in other cases, and Dr. Ahmed is not wanted in other cases. He will be released, God willing, either today or Saturday," Buheiri said. Friday is the weekend in Egypt.
(Editing by Alastair Macdonald)