CAIRO -- Egypt's military on Wednesday ousted Mohamed Morsi, the nation's first freely elected president, suspending the Constitution, installing an interim government and insisting it was responding to the millions of Egyptians who had opposed the Islamist agenda of Mr. Morsi and his allies in the Muslim Brotherhood.
The military intervention, which Mr. Morsi rejected as a "complete military coup," marked a tumultuous new phase in the politics of modern Egypt, where Mr. Morsi's autocratic predecessor, Hosni Mubarak, was overthrown in a 2011 revolution.
The intervention raised questions about whether that revolution would fulfill its promise to build a new democracy at the heart of the Arab world. The defiance of Mr. Morsi and his Brotherhood allies also raised the specter of the bloody years of the 1990s, when fringe Islamist groups used violence in an effort to overthrow the military government.
In an announcement read on state television, Gen. Abdul-Fattah el-Sisi, the Egyptian defense minister, said the military had taken the extraordinary steps not to seize power for itself but to ensure that "confidence and stability are secured for the people."
In Cairo's Tahrir Square, the symbolic epicenter of the Arab Spring revolutions, where anti-Morsi protesters have been massing in recent days calling for him to resign, the military's announcement was greeted with exultant cheers, fireworks and horn-honking.
In other gatherings elsewhere by Morsi supporters, there was anger. News services reported that in the city of Alexandria, opponents and supporters of Mr. Morsi clashed with rocks and bricks, and gunfire was heard.
Under a "road map" for a post-Morsi government devised by a meeting of civilian political and religious leaders, the general said, the Constitution would be suspended, the head of the Supreme Constitutional Court would become acting president and plans would be expedited for new elections while an interim government was in charge.
The general, who had issued a 48-hour ultimatum to Mr. Morsi on Monday to respond to what he called widespread anger over the administration's troubled one-year-old tenure, said the president's defiant response in a televised address on Tuesday had failed "to meet the demands of the masses of the people."
The general's announcement came after the armed forces had deployed tanks and troops in Cairo and other cities where pro-Morsi crowds were massing, restricted Mr. Morsi's movements and convened an emergency meeting of top civilian and religious leaders to devise the details of how the interim government and new elections would proceed.
"Those in the meeting agreed to a road map that includes initial steps to achieve building a strong and cohesive Egyptian society that does not exclude any of its sons or its currents and can end the state of struggle and division," General el-Sisi said his announcement.
Ahram Online, the government's official English-language Web site, said the military had informed Mr. Morsi that he was no longer head of state. There was no word on Mr. Morsi's whereabouts.
But in a statement e-mailed by his office, Mr. Morsi rejected the military's intervention.
"Dr. Mohamed Morsi, the president of the Arab Republic of Egypt, emphasizes that the measures taken by the General Command of the armed forces represent a complete military coup, which is categorically rejected by all the free of the country who have struggled so that Egypt turns into a civil democratic society," his statement said.
"His Excellency the president, as the president of the Republic and the chief commander of the armed forces, stresses that all citizens, civilians and in the military, leaders and soldiers, must commit to the Constitution and the law and to not respond to this coup that sets Egypt back and to maintain peacefulness in their performance and to avoid being involved in the blood of the people of the homeland," it said. "Everybody must shoulder their responsibilities before God and then before the people and history."
The military had signaled early in the day that it intended to depose Mr. Morsi. By 6:30 p.m., military forces began moving around Cairo. Tanks and troops headed for the presidential palace -- although it was unclear whether Mr. Morsi was inside -- while other soldiers ringed the nearby square where tens of thousands of the president's supporters were rallying.
Many of the Islamists had armed themselves with makeshift clubs, shields made of potcovers or metal scraps and plastic hard hats, and there were small scuffles with the better-armed soldiers. Some soldiers fired their weapons in the air, but the military forces held back.
Soldiers were also seen erecting barbed-wire fences and barriers around a barracks where Mr. Morsi may have been working.
Mr. Morsi's senior foreign policy adviser, Essam el-Haddad, issued an open letter on his Web page lamenting what he called a military coup.
Security officials said the military's intelligence service had banned any travel by Mr. Morsi and senior Islamist aides, including the Muslim Brotherhood's supreme guide, Mohamed Badie, and his influential deputy, Khairat el-Shater.
Gehad el-Haddad, a Brotherhood spokesman, vowed that the group would not bend in its defiance of the military. "The only plan," he said in a statement posted online, "is to stand in front of the tanks."
The Obama administration, which has been watching the crisis with increased worry, reiterated that it had taken no sides and hoped for a peaceful outcome. "We do, of course, remain very concerned about what we're seeing on the ground," a State Department spokeswoman, Jennifer R. Psaki, told reporters at a daily briefing. "And we do realize, of course, that is an extremely tense and fast-moving situation in Egypt."
The escalating tensions between Mr. Morsi's Islamist supporters and their opponents continued to spur street violence overnight. Egyptian officials said that at least 18 people had died and more than 300 were injured in fighting near an Islamist rally in support of Mr. Morsi near Cairo University. State media reported that the dead included victims from both sides and that most died of gunshot wounds.
Even before the military deadline expired, there were signs of a new crackdown on Mr. Morsi's allies in the Muslim Brotherhood. Police officials said Wednesday that they had arrested six bodyguards protecting the Brotherhood's spiritual leader.
The police initially reported that more than 40 Islamists had been wounded by birdshot, and Islamist witnesses said later that the police had begun shooting at them as well. But after the initial attack, the Islamists began lashing out and beating people suspected of being assailants. Opponents of the Islamists said they, too, were shooting as the fighting continued through the night.
By morning, the area around Cairo University was filled with burned cars, smoldering piles of garbage, makeshift barricades and torn textbook pages in English, French and German. Campaign posters from last year's historic presidential election still hung on the walls.
A few hundred Islamists and a smaller crowd of their opponents clustered in camps, both sides armed with clubs and sticks. A sign hung by Mr. Morsi's supporters declared: "To the coup supporters, our blood will haunt you, and you will pay an expensive price for every spilled drop of our blood."
Some of the Islamists gathered there belonged to more conservative factions than the Muslim Brotherhood and said the efforts to oust Mr. Morsi demonstrated that democracy itself could not be trusted. "Isn't this the democracy they wanted?" asked Mahmoud Taha, 40, a trader. "Didn't we do what they asked?"
"We don't believe in democracy to begin with; it's not part of our ideology. But we accepted it and we followed them and then this is what they do," he said. "They're protesting against an elected democracy."
His friend, who gave his name as Abu Hamza, 41, said: "This is a conspiracy against religion. They just don't want an Islamist group to rule."
All said they were bracing for a return to the repression Islamists endured under the government of Mr. Mubarak.
"Of course. What else are they going to do?" said Ahmed Sami, 22, a salesman.
Their opponents were vitriolic. "God willing, there will be no Muslim Brother left in the country today," said Mohamed Saleh, 52, a laborer armed with a long shaft of timber labeled "martyr in the making."
"Let them get exiled or find rocks to hide underneath like they used to do, or go to prisons, it doesn't matter," he said. "No such a thing as 'an Islamist party' shall exist after today."
The confrontation on the streets reflected an equally bitter clash at the most senior levels of state and military power.
"We swear to God that we will sacrifice even our blood for Egypt and its people, to defend them against any terrorist, radical or fool," the armed forces said on a military-affiliated Facebook page early Wednesday in a posting titled "Final hours." It was published shortly after Mr. Morsi delivered his angry, impassioned speech pledging to uphold the legitimacy of the elections that brought him to power last year.
The military posting quoted General el-Sisi as saying, "It was more honorable for us to die than to have the people of Egypt terrorized or threatened."
Brotherhood leaders have sounded increasingly alienated and determined to fight. "Everybody abandoned us, without exception," Mohamed el-Beltagy, a senior Brotherhood leader, declared in a statement posted online on Tuesday. "The police looks like it's assigned to protect one group of protesters and not the other," he wrote, "and maybe instead of blaming the thugs they will shortly accuse our supporters of assaulting themselves in addition to their alleged assault on the opposition."
"They want us to go away to prevent bloodshed," Ahmed Aref, a Brotherhood spokesman, said to a crowd of Morsi supporters not long after the president's speech. "We tried that before in the '50s, and people's blood was shed in prisons, detention centers and by the hands of dawn visitors for 20 years. Do you want this to happen again?"
"No!" the crowd cheered.
David D. Kirkpatrick and Ben Hubbard reported from Cairo and Alan Cowell from London. Kareem Fahim and Mayy El Sheikh contributed reporting from Cairo, and Mona El-Naggar and Rick Gladstone from New York.
This article originally appeared in The New York Times.