CAIRO — An Egyptian court Thursday ordered the release of former prime minister Ahmed Nazif, 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 Morsi prepare mass demonstrations on June 30 to mark the first anniversary of his taking office. 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, by Saturday,” Buheiri said. — Reuters