(Refiles to add dropped word "arrest" in paragraph two)
* Mubarak could be freed on Thursday
* Muted reaction to release of toppled strongman
* Mubarak still faces retrial for complicity in killings
* Mubarak to be put under house arrest
By Maggie Fick and Shadia Nasralla
CAIRO, Aug 21 (Reuters) - Egyptian leader Hosni Mubarak will leave jail as early as Thursday after a court ruling that jolted a divided nation already in turmoil seven weeks after the army toppled Islamist President Mohamed Mursi.
Mubarak will then be put under house arrest, the prime minister's office said in a statement. The decision was authorised under Egypt's Emergency Law recently enacted under a security crackdown on Islamists, it added.
By keeping Mubarak under house arrest, Egyptian leaders may be trying to show they will not be too lenient with him to avoid angering the many Egyptians who held mass protests that led to the end of his iron rule in 2011.
Two groups of activists have already called for sit-ins in Cairo to protest against his expected release.
Convening on Wednesday at the Cairo jail where Mubarak is held, the court ordered the release of the military man who ruled Egypt for 30 years until he was overthrown during the uprisings that swept the Arab world in early 2011.
Asked when his client would go free, Mubarak's lawyer, Fareed al-Deeb, told Reuters: "Maybe tomorrow".
Mubarak, 85, was sentenced to life in prison last year for failing to prevent the killing of demonstrators. But a court accepted his appeal earlier this year and ordered a retrial.
The ailing ex-president probably has no political future, but some Egyptians were indignant at the court ruling, which state prosecutor Ahmed el-Bahrawi said cannot be appealed.
"The army has brought back Mubarak's regime, the same regime," said Guma Abdel Alim, outside a bicycle shop in central Cairo. "Those who were elected by the people are now in prison."
He was referring to a widescale security sweep on Mursi's Muslim Brotherhood that has netted many of its leaders.
Shopworker Rubi Abdel Azim said Mubarak had been the worst ruler in Egypt's history, but a passerby in a worn-out shirt disagreed. "He was the greatest president," said Nagi Hassan.
Political turbulence has kept Egypt on edge for months. At least 900 people, including 100 soldiers and police, have been killed in a crackdown on Mursi supporters in the past week, making it the country's bloodiest internal episode in decades.
Mubarak's release could add to tensions in a country where the Muslim Brotherhood has accused the army of trying to bring back the old regime.
"Today there was a decision to release him. Naturally that will cause a backlash in large segments in the Egyptian street," said analyst Adel Soliman.
The Brotherhood has said it would never abandon efforts to restore Mursi to power, although a fierce state security crackdown appears to have hurt the group. In the past week, it has struggled to get people on the streets to protest.
Mursi's supporters called on Egyptians to hold "Friday of Martyrs" protests against the military takeover that ousted him.
A grouping calling itself the National Coalition to Support Legitimacy, which has been demanding Mursi's reinstatement, said in a statement: "We will remain steadfast on the road to defeating the military coup."
The United States and the European Union are both reviewing aid to Cairo in light of the bloodshed, but Saudi Arabia, a foe of the Brotherhood, has promised to make up any shortfall.
The European Union stopped short of agreeing immediate cuts in financial or military assistance to Cairo, as the bloc's foreign ministers held emergency talks on Wednesday to find ways to help bring an end to violence in Egypt.
The decision acknowledges Europe's limited economic muscle in forcing Egypt's army-backed rulers and Mursi's supporters into a peaceful compromise.
It also reflects a concern that abruptly cutting aid could shut dialogue with Cairo's military rulers and damage Europe's ability to mediate in any future negotiations to end the strife.
Egypt has repeatedly said it does not want foreign powers to interfere in its standoff with the Brotherhood.
"Egypt can never accept an interference in its sovereignty or the independence of its decisions or an interference in its internal affairs," Foreign Minister Nabil Fahmy said in a statement issued after the EU talks.
"The only standard that rules Egypt's decisions is the supreme interest of the country and its national security."
There was no immediate reaction to the ruling on Mubarak from the Brotherhood, whose leaders are mostly behind bars.
Mubarak is still being retried on charges of complicity in the killing of protesters during the revolt against him, but he has already served the maximum pre-trial detention in that case.
The court ruling removed the last legal ground for his imprisonment in connection with a corruption case, following a similar decision in another corruption case on Monday. Mubarak will not be allowed to leave Egypt and his assets remain frozen.
Mubarak's two sons, Gamal and Alaa, along with former Interior Minister Habib el-Adly, are still in prison, and Adly's lawyer said the ruling on Mubarak had no bearing on their cases.
Some of the liberal and secular politicians who backed the army's ousting of Mursi, Egypt's first freely elected president, on July 3, said they regretted Mubarak's release but the judiciary's decision should be respected.
"His regime was lousy and he destroyed the country," said Mohamed Abolghar, head of the Egyptian Social Democratic Party, to which the army-appointed interim prime minister belongs.
Noting Mubarak's age and the jail time he has served, he said: "We should focus on building the country, establishing democracy and finishing the problem of the Muslim Brotherhood.
"The government knows that if Mubarak is freed there will be public outrage, but a court decision is a court decision."
Khaled Dawoud, spokesman of the liberal Dostour Party, said the trials of the ex-president and his associates had all been flawed because the judiciary was ill-equipped to deal with cases related to Mubarak's rule, resulting in a series of acquittals.
"It was a faulty process from the beginning," he said.
The relatively muted response from Mubarak's non-Islamist opponents may reflect a reluctance to rock the boat following the army's removal of Mursi, which they had endorsed.
The generals say they were responding to the will of the people after vast demonstrations organised by liberals and leftists demanding Mursi's ouster. They have installed an interim administration to oversee a roadmap back to democracy.
The authorities now portray their quarrel with the Brotherhood, Egypt's best-organised political force, as a fight against terrorism and are jailing its leaders. They detained the group's "general guide", Mohamed Badie, in Cairo on Tuesday.
Saudi Arabia and the United Arab Emirates, which along with Kuwait have promised Egypt $12 billion in aid since Mursi's ouster, have frowned on Mubarak's detention all along. Arab diplomats said the conservative Gulf monarchies had lobbied for the release of a man they once valued as a strong regional ally.
Mubarak's jailing and trial, when he appeared in a courtroom cage, also affronted some Egyptian officers. One colonel, who asked not to be named, said the treatment of the former supreme military commander had "tarnished the army's image".
Lobna Moneib, spokeswoman of the leftist Popular Current movement, said the court ruling posed a problem. "We think he is guilty and have called for him to be tried by revolutionary courts," she said, advocating such trials for all Mubarak-era officials as well as for Mursi and his Brotherhood colleagues.
The United States, a close ally of Egypt since Cairo signed a peace treaty with Israel in 1979, said on Tuesday that the crackdown on protesters could influence U.S. aid. It denied reports it had already suspended assistance.
At issue is the future of about $1.23 billion in U.S. military assistance and $241 million in economic aid to Egypt.
Western nations were uneasy during Mursi's year in power, when he rammed through an Islamist-tinged constitution.
Washington has not denounced the army takeover as a "coup", which under U.S. law would force a suspension of aid. The ensuing bloodshed, however, has dismayed the West.
U.S. Senator John McCain, a former Republican presidential nominee, said on Wednesday: "The slaughter of hundreds of Egyptians in the street is appalling to all of us."
He said U.S. aid should be conditioned on a change in the constitution and scheduling of elections as soon as possible. "The present government is representative of no one," he said.
The arrest of Badie, the Brotherhood's leader, is part of a wave of detentions among the upper echelons of the organisation.
Murad Ali, a media adviser to the Brotherhood's political party, and Safwat Hegazy, a fiery preacher, were arrested while trying to flee the country, state media reported on Wednesday.
The Brotherhood said the crackdown would prove futile.
"The putschists think that arresting the leaders of the Muslim Brotherhood and marring their image in the media will make Egyptians bow and give in to the coup," it said.
"They have killed thousands, wounded thousands, arrested thousands but the (people) are continuing in their peaceful revolution, rejecting the coup and military rule." (Additional reporting by Cairo bureau, Justyna Pawlak and John O'Donnell in Brussels, Lesley Wroughton and Patricia Zengerle in Washington, and Elaine Lies in Tokyo; Writing by Alistair Lyon; Editing by Michael Georgy, Will Waterman and Alastair Macdonald)