Egypt's army has plans to push Mohamed Morsi aside and suspend the constitution after an all but impossible ultimatum it has given the Islamist president expires in less than 24 hours, military sources told Reuters on Tuesday.
Meanwhile, Morsi has defiantly declared that he will not step down, despite a demand by huge numbers of demonstrators that he do so.
Morsi went on national television late Tuesday and reminded viewers that he was democratically elected more than a year ago. He said he intends to carry out his constitutional duties, despite mass protests demanding his resignation.
The Egyptian president also demanded that the military withdraw its threat to intervene in the country's political crisis. The military has warned that it will impose a roadmap for Egypt's future if differences between Morsi and his opponents are not resolved by Wednesday.
Condemning a coup against their first freely elected leader, tens of thousands of Morsi's Muslim Brotherhood supporters took to the streets, clashing with opponents in several towns. But they appeared to be dwarfed by anti-government protesters who turned out in their hundreds of thousands across the nation.
Troops were on alert after warnings of a potential civil war. Seven people died in fighting in Cairo suburbs and hundreds were wounded in the provinces.
Morsi defied a demand by the armed forces chief on Monday that he agree to share power with his opponents within 48 hours or have the generals take charge. Calling the army statement misleading and divisive, he said he would stick to his own plan.
But time has all but run out for Morsi, as liberal leaders are refusing to talk to him. Opponents have been dancing in the streets since the intervention by General Abdel Fattah al-Sisi.
Military sources told Reuters that, assuming the politicians failed to end a year of deadlock under Morsi before Wednesday's 5 p.m. (1500 GMT) deadline, the generals had their own draft programme ready to implement - though it could be fine-tuned in consultation with willing political parties.
Under the roadmap, the military would install an interim council, composed mainly of civilians from different political groups and experienced technocrats, to run the country until an amended constitution was drafted within months.
That would be followed by a new presidential election, but parliamentary polls would be delayed until strict conditions for selecting candidates were in force, the sources said.
They would not say how the military intended to deal with Morsi if he refused to go quietly. One power he might seek to exercise would be to call a referendum on continuing his term.
Some of his Islamist supporters have vowed to defend what they see as the legitimate, democratic order, even if it means dying as martyrs. And some have a history of armed struggle against the state.
The confrontation has pushed the most populous Arab nation closer to the brink of chaos amid a deepening economic crisis two years after the overthrow of Hosni Mubarak, raising concern in Washington, Europe and neighboring Israel.
Troops intervened to break up clashes in the Mediterranean city of Alexandria. They were also out on the streets of Suez and Port Said, at either end of the Suez Canal. The waterway is vital to world trade and to Egypt's struggling economy.
Morsi was looking increasingly isolated as ministers and officials who are not members of his Muslim Brotherhood resigned. He also lost a judicial battle when a court evicted his prosecutor-general and reinstated a Mubarak appointee.
Egypt's Coptic Pope, spiritual leader of the country's 10 percent Christian minority, expressed open support for the anti-Morsi Tamarud (Rebel) movement in a tweet, voicing support for the trio of people, army and youth.
The leading Muslim religious authority, Al-Azhar, called for the will of the people to prevail peacefully.
Morsi met Sisi for a second day, his office said, along with Prime Minister Hisham Kandil. A presidential aide told the state news agency there had been no "disagreements" but there was no outward sign of a meeting of minds.
Though Morsi has held out repeated offers of dialogue, liberal opponents accuse him and the Brotherhood of bad faith and have ruled out starting talks with him before the deadline.
After that, former U.N. nuclear agency chief Mohamed ElBaradei will deal directly with the military on behalf of the main coalition of liberal parties. Also planning to take part are leaders of the Tamarud youth movement, which initiated mass rallies on Sunday that the army says prompted it to act.
Military sources said the armed forces would talk with the opposition National Salvation Front and other political, religious and youth organizations after the deadline.
Among figures being considered as an interim head of state was the new president of the constitutional court, Adli Mansour.
The new transition arrangements would be entirely different from the military rule that followed Mubarak's fall and more politically inclusive, the sources said.
Then, the ruling armed forces' council was widely criticised by liberal and left-wing politicians for failing to enact vital economic and political reforms - and for siding with the Brotherhood.
Fighting between Morsi supporters and opponents broke out in the Cairo suburb of Giza, in Alexandria and in the town of Qalyubia, north of Cairo, security sources said.
Protesters thonged Cairo's Tahrir Square, where hovering military helicopters got loud cheers. A quarter of a million packed the square after work, celebrating wildly what they believe is Morsi's impending departure.
Senior Muslim Brotherhood leaders branded the military ultimatum a "coup", backed by a threat that the generals will otherwise impose their own road map for the nation.
The Brotherhood's political wing called for mass counter- demonstrations to "defend constitutional legitimacy and express their refusal of any coup", raising fears of violence. But the biggest pro-Morsi rally in the a Cairo suburb appeared to attract around 100,000 supporters, Reuters witnesses said.
The Brotherhood long avoided direct confrontation with the security forces despite suffering oppression under Mubarak.
After millions protested on Sunday, Sisi delighted Morsi's opponents by effectively ordering the president to heed the demands of the street. It took the president's office nine hours to respond with a statement indicating he would go his own way.
"The president of the republic was not consulted about the statement issued by the armed forces," it said. "The presidency confirms that it is going forward on its previously plotted path to promote comprehensive national reconciliation ... regardless of any statements that deepen divisions between citizens."
Describing civilian rule as a great gain from the revolution of 2011, Morsi said he would not let the clock be turned back.
The United States, which has previously defended Morsi's legitimacy as a democratically elected leader, stepped up pressure on him to heed the mass protests but stopped short of saying he should step down.
President Barack Obama told Morsi in a phone call late on Monday that the political crisis could only be solved by talks with his opponents, the White House said.
Secretary of State John Kerry hammered home the message in a call to his outgoing Egyptian colleague on Tuesday.
At least six ministers who are not Brotherhood members have tendered their resignations since Sunday, including Foreign Minister Mohamed Kamel Amr. The president's two spokesmen and the cabinet spokesman also quit on Tuesday and nearly 150 Egyptian diplomats signed a petition urging Morsi to go.
Senior Brotherhood politician Mohamed El-Beltagy denounced what he called a creeping coup. He said he expected the High Committee for Elections to meet within hours to consider annulling the 2012 presidential election.
The United States has long funded the Egyptian army as a key component in the security of Washington's ally Israel.
General Martin Dempsey, chairman of the U.S. Joint Chiefs of Staff, spoke to his Egyptian counterpart on Monday. It is unclear how far the military has informed, or coordinated with, its U.S. sponsors but an Egyptian official said a coup could not succeed without U.S. approval.
The United Nations Human Rights office called on Morsi to listen to the demands of the people and engage in a "serious national dialogue" but also said: "Nothing should be done that would undermine democratic processes."
A senior European diplomat said that if the army were to remove the elected president, the international community would have no alternative but to condemn it.
Yasser El-Shimy, Egypt analyst at the International Crisis Group, said the army ultimatum had hardened positions, making it very difficult to find a constitutional way out of the crisis.
"Things could deteriorate very rapidly from there, either through confrontations on the street, or international sanctions," he said.
"Morsi is calling their bluff, saying to them, 'if you are going to do this, you will have to do it over my dead body'."
For many Egyptians, fixing the economy is key. Unrest since Mubarak fell has decimated tourism and investment and state finances are in poor shape, drained by extensive subsidies for food and fuel and struggling to provide regular supplies.
The Cairo bourse, reopening after a holiday, shot up nearly 5 percent after the army's move.