CAIRO (CNN) -- Egypt's military toppled the country's first democratically elected president Wednesday night, installing the country's chief justice as an interim leader as the deposed Mohamed Morsy insisted on his legitimacy.
In a nationally televised announcement, Gen. Abdel-Fatah El-Sisi said Morsy "did not achieve the goals of the people" and failed to meet the generals' demands that he share power with his opposition.
The country's constitution has been suspended, new parliamentary elections will be held and Adly Mansour, head of the country's Supreme Constitutional Court, will replace Morsy, El-Sisi said.
Mansour will have the power to issue constitutional declarations during the interim period and will "establish a government that is a strong and diverse," said El-Sisi, head of the country's armed forces.
He said the military was fulfilling its "historic responsibility" to protect the country by ousting Morsy, a Western-educated Islamist elected a year ago.
In a taped statement delivered to the Arabic satellite network Al Jazeera, Morsy remained defiant and insisted he was Egypt's proper president.
"The world is looking at us today," he said. "We by ourselves can bypass the obstacles. We, the sons of Egypt, the sons of this country -- this is the will of the people, and cannot be canceled."
Shortly after the statement aired, Al Jazeera reported its Egyptian offices had been raided and some of its staff detained. And the Muslim Brotherhood, the political movement that propelled Morsy to office, said its outlets had been shut down.
Morsy said he remains open to negotiations and dialogue, and he called on supporters to demonstrate peacefully.
But at least four people were killed in clashes between Morsy's supporters and security forces in the northern city of Marsa Matrouh, and dozens more were hurt in Kafr El-Sheikh, where at least 43 Morsy supporters were arrested, the state-run newspaper Al-Ahram reported.
Morsy opponents who packed Tahrir Square, now the epicenter of two Egyptian upheavals, erupted in jubilation and fireworks when El-Sisi made his announcement. But across the Nile River, his supporters chanted chanted "Down with military rule" and "The square has a million martyrs" at another rally.
Before Wednesday night's announcement, troops moved into key positions around the capital, closing off a bridge over the Nile River and surrounding Rabaa Adawya Square, where Morsy's supporters were gathered.
Military had demanded reforms
Morsy was elected president in June 2012. But his approval ratings have plummeted as his government has failed to keep order or revive Egypt's economy. The chaos, including open sexual assaults on women in Egypt's streets, has driven away tourists and investors, while opponents say Morsy's rule was increasingly authoritarian.
Mohamed ElBaradei, the former head of the International Atomic Energy Agency and a leading opposition figure, said the plans announced Wednesday were "a correction for the way of the revolution" that drove longtime strongman Hosni Mubarak from office in 2011.
"The road map guarantees achieving the principal demand of the Egyptian people -- having early presidential elections through an interim period through which the constitution will be amended," he said. "So all of us build it together and agree on a democratic constitution, so we can guarantee our freedoms."
The Egyptian military dominated the country for six decades and took direct power for a year and a half after Mubarak's ouster. On Monday, after a previous demand that Morsy offer concessions to the opposition, it gave him 48 hours to order reforms.
As the hour of the ultimatum neared, Morsy offered to form an interim coalition government to oversee parliamentary elections and revise the constitution that was enacted in January.
"One of the mistakes I cannot accept -- as the president of all Egyptians -- is to side with one party over another, or to present the scene from one side only. To be fair, we need to listen to the voice of people in all squares," he said.
But shortly after the deadline, Morsy aide Essam El Haddad said in a Facebook posting that a coup was under way and warned that the generals risked bloodshed by moving against Morsy.
"In a democracy, there are simple consequences for the situation we see in Egypt: The president loses the next election or his party gets penalized in the upcoming parliamentary elections. Anything else is mob rule," he wrote.
But Naguib Abadeer, a member of the opposition Free Egyptians Party, said what was under way "is not by any means a military coup. This is a revolution."
Morsy lost his legitimacy in November, when he declared courts could not review his decrees and ousted the country's prosecutor-general, Abadeer said. And the Muslim Brotherhood "hijacked the vote of the people" by running on a religious platform, "so these were not democratic elections," he said.
Coup followed massive protests by two sides
In Washington, State Department spokeswoman Jen Psaki said the U.S. government -- Egypt's leading ally -- could not confirm reports of a coup. Psaki said the United States is not taking sides and urged all parties to come to a peaceful resolution to the "tense and fast-moving" situation.
Washington has supplied Egypt's military with tens of billions in support and equipment over more than 30 years. Under U.S. law, that support could be cut off after a coup, though a senior Obama administration official told CNN that any decision would require thorough analysis.
The opposition said it had collected more than 20 million signatures on a petition to remove him -- millions more than the number who voted Morsy into the presidency.
Tuesday night, Morsy had vowed that he would not comply with the ultimatum and demanded that the armed forces stand down, even "if the price of upholding this legitimacy is my own blood." But political analyst Hisham Kassem told CNN the speech was Morsy's "final bluff."
"He was trying to give the impression 'We are there in numbers, and we are going to retaliate, we are not going to allow this to happen.' However, with almost 24 hours since his message, it's clear his supporters will not dare challenge the crowds on the street," Kassem said.
And faced with the throngs that filled Cairo's Tahrir Square, "the military had to intervene. Otherwise this crowd was going to get Morsy from his palace."
CNN spells the deposed president's name with a 'y' in accordance with what his spokesman said is his personal preference, his own e-mail and the country's Foreign Ministry.
Wednesday's events capped days of massive demonstrations for and against Morsy. The demonstrations were largely peaceful, but health officials said 23 people died in clashes overnight at Cairo University, the state-funded Al-Ahram news agency reported, and anti-Morsy demonstrators have ransacked Muslim Brotherhood offices around Egypt in the past several days.
El-Haddad, the Muslim Brotherhood spokesman, said Wednesday that tanks and armored vehicles -- accompanied by thugs carrying knives, pistols and ammunition -- had been moved to the northern and southern entrances of the square in an apparent attempt to drive them out.
The military fired warning shots into the air, and shot one Muslim Brotherhood member in the leg, El-Haddad said, but the remaining protesters were standing in defiance in front of the tanks. The military denied any shots had been fired.
Morsy's government was already crumbling before the coup. Five cabinet ministers resigned this week, including Foreign Minister Mohamed Kamel Amr. And former Prosecutor General Abdel-Meguid Mahmoud will meet Thursday with the Supreme Judicial Council to be confirmed in the job.
Mahmoud had originally been installed in the job by Mubarak, shortly before he left. One of the goals during the 2011 revolution had been to oust him, which Morsy did through last November's constitutional declarations.
Mahmoud's return appeared to signify a tilt toward Mubarak-era officials over Muslim Brotherhood loyalists.
In addition, 30 members of the Shura Council, the upper house of parliament, have resigned, state-run Nile TV reported.
Morsy's numerous and adamant supporters point out that he is the legitimate president and say that opponents seeking to depose him are circumventing the democratic process. The unrest prompted U.S. President Barack Obama to call Morsy on Monday and urge a less rigid stance.
"He stressed that democracy is about more than elections," a White House statement said.
But the administration appeared to be giving mixed signals on where it stands. On Tuesday, Obama called on Morsy to hold early elections, a senior administration official said.
"We are saying to him, 'Figure out a way to go for new elections,'" the official said. "That may be the only way that this confrontation can be resolved."
A State Department spokeswoman, however, denied that Obama urged early elections.