Egypt's armed forces handed Islamist President Mohamed Morsi a virtual ultimatum to share power on Monday, giving feuding politicians 48 hours to compromise or have the army impose its own roadmap for the country.
A dramatic military statement broadcast on state television declared the nation was in danger after millions of Egyptians took to the streets on Sunday to demand that Morsi quit and the headquarters of the ruling Muslim Brotherhood were ransacked.
Since the fall of Hosni Mubarak more than two years ago as the Arab Spring revolutions took hold, the Arab world's most populous nation has remained in turmoil, arousing concern amongst allies in the West and in Israel, with which Egypt has had a peace treaty since 1979.
Morsi's backers were furious at the military statement: "The age of military coups is over," said Yasser Hamza of the Brotherhood parliamentary wing.
But it provoked delight among liberal leaders and crowds in Cairo's Tahrir Square, who cheered when a flight of military helicopters swooped overhead trailing national flags. Silhouetted against the sunset, it was a powerful illustration of the military's desire to be seen in tune with the people.
"If the demands of the people are not realized within the defined period, it will be incumbent upon (the armed forces) ... to announce a road map for the future," chief-of-staff General Abdel Fattah al-Sisi said in the statement that was followed by patriotic music.
The people had expressed their will with unprecedented clarity in the mass demonstrations and wasting more time would only increase the danger of division and strife, he said.
The army said it would oversee the implementation of the roadmap it sought "with the participation of all factions and national parties, including young people", but it would not get directly involved in politics or government.
Anti-Morsi demonstrators outside the presidential palace cheered the army statement, and the main opposition National Salvation Front, which has demanded a national unity government for months, applauded the military's move. The army is held in high regard, especially after it helped topple Mubarak.
On Cairo's Tahrir Square, thousands were celebrating the army's move: "We want a new armed forces council to govern until new elections," said accountant Mohamed Ibrahim, 50. "The army alone supports the legitimate revolutionary will of the people."
"The invitation to meet the demands of the people within the next few hours is a historic opportunity which should not be lost," said Amr Moussa, a liberal politician and former foreign minister who stood in last year's presidential election.
There was no immediate reaction from the president's office.
It was the second time in just over a week that the armed forces had issued a formal warning to the politicians, piling pressure on Morsi to concede power-sharing with the liberal, secular and left-wing opposition.
Analysts said the military intervention could serve Morsi if he wished to compromise, but it risked giving his opponents an incentive to harden their demands, sensing support from the street and the generals, at the risk of triggering a coup.
"The ultimatum has the ring of a potential coup," said Yasser al-Shimy of the International Crisis Group think-tank.
"What makes it not a coup is it gives time for the politicians to sort out their differences."
The second biggest Islamist group in parliament, the Nour Party, said it feared the return of army rule "in a big way".
The armed forces have played an important role in Egyptian politics since army officers staged the overthrow of the monarchy in 1952.
After the destruction of its offices, the Brotherhood which operated underground until the overthrow of Mubarak in 2011, said it was considering how best to defend itself.
Sunday's mass rallies were bigger than anything seen since the Arab Spring uprising. Smaller crowds returned to Tahrir Square and other gathering points on Monday afternoon.
Five non-Brotherhood government ministers tendered their resignations from the cabinet, apparently in sympathy with the protesters, underlining a sense of isolation for the party that won a series of elections last year.
"Both sides are still in their trenches," a senior European diplomat said just before the military statement.
Eight people died in a night of fighting around the Brotherhood building, where guards fired on youths hurling rocks and fire bombs. A Brotherhood official said two of its members were hurt. Another eight people were killed and 731 injured in clashes around the country on Sunday, the health ministry said.
The Brotherhood's official spokesman told Reuters that the attack had crossed a red line of violence and among possible responses might be to revive "self-defense committees" former during the 2011 uprising.
"The people will not sit silent," Gehad El-Haddad said.
Morsi's movement complained at the lack of police protection, which can only heighten its sense of being under siege from both the liberal opposition and state officialdom inherited from the old regime.
Protesters opposing Egyptian President Mohamed Morsi at Tahrir Square in Cairo on July 1. Photo by Suhaib Salem/Reuters
Liberal protest organizers, who declared Morsi ousted by people power on Sunday, said they hoped people would stay in the streets until Morsi left.
Morsi, who has not appeared in person, earlier renewed offers via allies of dialogue and pledged to work with a new parliament if disputes over election rules can be ironed out. But he has so far offered no substantial concessions.
The opposition does not trust the Islamist movement, which critics accuse of using a series of electoral victories to monopolize power. They want a total reset of the rules of a democracy imperfectly worked out over the past two years.
The massive protests showed that the Brotherhood has not only alienated liberals and secularists by seeking to entrench Islamic rule, notably in a new constitution, but has also angered millions of Egyptians with economic mismanagement.
Tourism and investment have dried up, inflation is rampant and fuel supplies are running short, with power cuts lengthening in the summer heat and motorists spending hours fuelling cars.
The cost of insuring government debt against default surged to record highs. Forward contracts indicated a significant fall for the pound against the dollar.
Some uniformed policemen marched among protesters in Cairo and Alexandria, chanting "the police and the people are one", and several senior officers addressed the Tahrir Square crowd.
Adding to the failure to protect the Brotherhood headquarters, that cast doubt on whether Morsi could rely on the security forces to clear the streets if he gave the order.
The United States and the European Union have urged Morsi to share power with the opposition, saying only a national consensus can help Egypt overcome a severe economic crisis and build democratic institutions.
U.S. President Barack Obama renewed a call for Morsi and his adversaries to cooperate, just as Sisi's statement was made.
The Pentagon, which funds the Egyptian army heavily, said it could not speculate on what was about to happen in Egypt.
Military helicopters fly above Tahrir Square while protesters opposing Egyptian President Mohamed Morsi shout slogans against him and Brotherhood members during a protest in Cairo on July 1. Photo by Mohamed Abd El Ghany/Reuters
Reporting by Asma Alsharif, Alexander Dziadosz, Shaimaa Fayed, Maggie Fick, Alastair Macdonald, Shadia Nasralla, Tom Perry, Yasmine Saleh, Paul Taylor and Patrick Werr in Cairo; Writing by Paul Taylor; Editing by Alastair Macdonald and Giles Elgood