By Tom Perry and Yasmine Saleh
CAIRO (Reuters) - Hosni Mubarak's last prime minister, Ahmed Shafik, will soon be free to return from self-imposed exile and perhaps to make a political comeback after Egyptian courts on Thursday acquitted him in a corruption case and shelved another.
Shafik left Egypt last year after he was defeated in the presidential election by the Muslim Brotherhood's Mohamed Mursi.
Several corruption cases were brought against Shafik during Mursi's rule, which was cut short in July when he was deposed by the army after mass protests against his rule.
Judicial sources said the court had sent the final case against Shafik back to the prosecutor, who must now decide whether to dismiss it or order more investigations into the charges, which relate to illegal allocation of state-owned land.
A separate ruling acquitted Shafik and Mubarak's two sons, Alaa and Gamal, in a different corruption case. Alaa and Gamal Mubarak remain in prison charged in other corruption cases.
The rulings mean Shafik's name will be removed within days from a list of people whose arrest has been ordered, assuming no other cases are filed against him, judicial sources said.
Shafik's return would reflect the shifting balance of power in Egypt since the army removed Mursi and set the Arab world's largest nation on a new political course designed to lead to presidential and parliamentary elections next year.
The courts have been a frontline in Egypt's political struggle. Following Mubarak's fall in 2011, an array of cases were brought against the veteran autocrat and his aides.
But the pattern has changed since Mursi's removal: Mubarak has been freed from prison, though is being retried on charges of ordering the killing of protesters in 2011.
This week, the prosecutor unveiled a new case against Mursi and his Brotherhood colleagues, ordering him and 35 others to stand trial for terrorism and conspiring with foreign groups - charges for which they could be executed.
The Brotherhood on Thursday denounced the case, which accuses it of hatching "a terrorist plan" dating back to 2005 and implicates the Palestinian group Hamas, the Shi'ite Islamist government of Iran and its Lebanese ally Hezbollah.
"The junta's judges continue to fabricate risible allegations against the democratically elected president and a number of leaders of the Muslim Brotherhood," it said.
The government accuses the Brotherhood of using violence. The group denies that charge, saying it is only protesting peacefully against what its supporters call a bloody coup.
Shafik narrowly lost to Mursi in the 2012 election, Egypt's first free and fair presidential vote. A former air force commander, Shafik was depicted by his opponents as a symbol of Mubarak's era. He cited Mubarak as a role model during his election campaign.
In an interview in September, he said he would not run for the presidency if army chief General Abdel Fattah al-Sisi did, saying the man who toppled Mursi had his full support.
Sisi has yet to say if he will run or not. He enjoys wide support among those Egyptians who rejoiced at Mursi's overthrow, but is reviled by the ousted president's supporters.
The presidential and parliamentary elections will be held after a referendum on a new constitution, which has been set for mid-January. Dates for the elections have yet to be set.
(Reporting by Yasmine Saleh and Tom Perry; Editing by Alistair Lyon)