* Armed forces declares nation in danger, urges compromise
* If no political deal in 48 hours, army will present plan
* Huge crowds turn out again to welcome army intervention
* Muslim Brotherhood HQ ransacked, police absent
Egypt's armed forces handed Islamist President Mohamed Mursi a virtual ultimatum to share power on Monday, giving feuding politicians 48 hours to compromise or have the army impose its own road map 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 Mursi quit and the headquarters of the ruling Muslim Brotherhood were ransacked.
The generals' intervention was greeted with delight among protesters in the streets - and muted dismay by Islamists.
Since the fall of Hosni Mubarak as the Arab Spring revolutions took hold more than two years ago, the Arab world's most populous nation has remained in turmoil, arousing concern among allies in the West and in neighbouring Israel, with which Egypt has had a peace treaty since 1979.
Mursi's allies were angry: "The age of military coups is over," said the Brotherhood's Yasser Hamza. Mohamed El-Beltagy said Islamists would take to the streets to show their strength. Mursi himself did not respond all day.
Crowds in Cairo's Tahrir Square 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 realised within the defined period, it will be incumbent upon (the armed forces) ... to announce a road map for the future," the chief of staff, General Abdel Fattah al-Sisi, said in the statement. It was followed by martial music.
The people had expressed their will with unprecedented clarity in the mass demonstrations, he said, and wasting more time would only increase the danger of division and strife.
The army said it would oversee the implementation of the road map 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.
Mursi's office said later the president met Sisi and Prime Minister Hisham Kandil, releasing a picture of them seated together smiling, but did not respond to the military statement.
Anti-Mursi 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. Spokesman Khaled Dawoud made clear there would be no talks with Mursi - he must quit and, once the 48 hours were up, they would deal with Sisi.
On Tahrir Square, thousands celebrated the army's move with a fervour that recalled its unsentimental removal of Mubarak at the end of 18 days of protests and bloodshed: "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."
Amr Moussa, a liberal politician and former foreign minister who stood in last year's presidential election, said, "The invitation to meet the demands of the people within the next few hours is a historic opportunity which should not be lost."
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 Mursi to concede power-sharing.
Analysts said the military intervention could serve Mursi if he wished to compromise, but it risked emboldening his opponents to harden their demands, 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" and urged Mursi to compromise with his opponents.
A later military statement denied the move was a "coup" and was only a response to the "pulse of the Egyptian street."
The armed forces have influenced Egyptian politics since army officers staged the overthrow of the monarchy in 1952.
They also receive significant funding from the United States, whose top military officer, General Martin Dempsey, called the chief of staff of Egypt's armed forces on Monday morning, a U.S. defense official told Reuters, without giving details of the conversation.
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.
Mursi supporters congregated near a Cairo mosque that has been their focus for the past 10 days. Some were bitter at the irony of liberal leaders embracing the army.
"The world always thought we Islamists didn't believe in democracy," said Hassan al-Sherbeny. "Now Islamists are teaching Egyptians democracy while the liberals are giving up democracy.
"And where is the world's reaction to all that?"
In a formal joint response to Sisi's statement, Islamist groups including the Brotherhood were careful not to criticise the army itself, instead saying that their political opponents were trying to manipulate it in a way that would lead to a coup.
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 but has failed to build out alliances to form a broader consensus.
"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 headquarters, where guards fired on youths hurling rocks and fire bombs. A Brotherhood official said two of its members were hurt. Eight other people were killed and 731 injured in clashes around the country on Sunday.
Unknown attackers also fire bombed the headquarters of the moderate Islamist Wasat party allied with the Brotherhood. The party called in a statement for dialogue among all parties.
Security sources said security forces arrested 15 bodyguards of Brotherhood deputy leader Khairat El-Shater after an exchange of gunfire with them outside his home. The guards are suspected of illegal possession of firearms used in the shooting at the movement's headquarters, the sources said.
The Brotherhood's political wing denied the arrests, saying only Shater's driver had been "kidnapped".
The Brotherhood's official spokesman told Reuters that the attack on its headquarters had crossed a red line of violence and among possible responses might be to revive "self-defence committees" former during the 2011 uprising.
"The people will not sit silent," Gehad El-Haddad said.
Mursi's movement complained about 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 government.
Mursi, 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 monopolise 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 had not only alienated liberals and secularists by seeking to entrench Islamic rule, notably in a new constitution, but had 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. An independent police association said it stood with demonstrators and would not let them down.
The United States and the European Union have urged Mursi to share power with the opposition, saying only a national consensus can help Egypt overcome a severe economic crisis and build democratic institutions.