By HAMZA HENDAWI, MAGGIE MICHAEL and SARAH EL DEEB
CAIRO (AP) -- Egypt's first democratically elected president was overthrown by the military Wednesday, ousted after just one year in office by the same kind of Arab Spring uprising that brought the Islamist leader to power.
The armed forces announced they would install a temporary civilian government to replace Islamist President Mohammed Morsi, who denounced the action as a "full coup" by the generals. They also suspended the Islamist-drafted constitution and called for new elections.
Millions of anti-Morsi protesters around the country erupted in celebrations after the televised announcement by the army chief. Fireworks burst over crowds in Cairo's Tahrir Square, where men and women danced, shouting, "God is great" and "Long live Egypt."
Fearing a violent reaction by Morsi's Islamist supporters, troops and armored vehicles deployed in the streets of Cairo and elsewhere, surrounding Islamist rallies. Clashes erupted in several provincial cities when Islamists opened fire on police, with at least nine people killed, security officials said.
Gehad el-Haddad, a spokesman for the Muslim Brotherhood party, said Morsi was under house arrest at a Presidential Guard facility where he had been residing, and 12 presidential aides also were under house arrest.
The army took control of state media and blacked out TV stations operated by the Muslim Brotherhood. The head of the Brotherhood's political wing was arrested.
The ouster of Morsi throws Egypt on an uncertain course, with a danger of further confrontation. It came after four days of mass demonstrations even larger than those of the 2011 Arab Spring that toppled longtime autocrat Hosni Mubarak.
Egyptians were angered that Morsi was giving too much power to his Muslim Brotherhood and other Islamists and had failed to tackle the country's mounting economic woes.
Beyond the fears over violence, some protesters are concerned whether an army-installed administration can lead to real democracy.
President Barack Obama urged the military to hand back control to a democratic, civilian government as soon as possible but stopped short of calling it a coup d'etat.
He said he was "deeply concerned" by the military's move to topple Morsi's government and suspend Egypt's constitution. He said he was ordering the U.S. government to assess what the military's actions meant for U.S. foreign aid to Egypt -- $1.5 billion a year in military and economic assistance.
The U.S. wasn't taking sides in the conflict, committing itself only to democracy and respect for the rule of law, Obama said.
On Monday, army chief Gen. Abdel-Fattah el-Sissi had given Morsi an ultimatum to find a solution to meet the demands of anti-government demonstrators in 48 hours, but the 62-year-old former engineer defiantly insisted on his legitimacy from an election he won with 51.7 percent of the vote in June 2012.
Any deal was a near impossibility, however, making it inevitable the military would move.
As the deadline approached, el-Sissi met with pro-reform leader Mohammed ElBaradei, top Muslim cleric Sheik Ahmed el-Tayeb and Coptic Pope Tawadros II, as well as opposition activists and some members of the ultraconservative Salafi movements. The consultations apparently were aimed at bringing as wide a consensus as possible behind the army's moves.
The Brotherhood boycotted the session, according to its political arm the Freedom and Justice Party.
In a last-minute statement before the deadline, Morsi again rejected the military's intervention, saying abiding by his electoral legitimacy was the only way to prevent violence. He criticized the military for "taking only one side."
"One mistake that cannot be accepted, and I say this as president of all Egyptians, is to take sides," he said in the statement issued by his office. "Justice dictates that the voice of the masses from all squares should be heard," he said, repeating his offer to hold dialogue with his opponents.
"For the sake of Egypt and for historical accuracy, let's call what is happening by its real name: Military coup," Morsi's top foreign policy adviser Essam al-Haddad wrote on his Facebook page.
After the deadline expired, el-Sissi went on state TV and said the chief justice of the Supreme Constitutional Court, Adly Mansour, would step in as interim president until new elections are held. Mansour was appointed to the court by Mubarak but elevated to the chief justice post by Morsi and will be sworn in Thursday by judges of his court.
Flanked by Muslim and Christian clerics as well as ElBaradei and two opposition activists, el-Sissi said a government of technocrats would be formed with "full powers" to run the country.
He promised "not to exclude anyone or any movement" from further steps. But he did not define the length of the transition period or when presidential elections would be held. He also did not mention any role for the military.
The constitution, drafted by Morsi's Islamist allies, was "temporarily suspended," and a panel of experts and representatives of all political movements will consider amendments, el-Sissi said. He did not say whether a referendum would be held to ratify the changes, as customary.
ElBaradei, a Nobel Peace Prize laureate and the former head of the U.N. nuclear watchdog agency, said he hoped the military plan "is the beginning of a new launch for the Jan. 25 revolution when people offered their dearest to restore their freedom, dignity and social justice for every Egyptian."
Also appearing with el-Sissi was Mahmoud Badr, one of two representatives of Tamarod, or Rebel -- the youth opposition movement that engineered the latest wave of protests. He urged protesters "to stay in the squares to protect what we have won."
After the speech, fireworks burst over crowds dancing and waving flags in Cairo's Tahrir Square, epicenter of the 2011 uprising. Now it was one of multiple centers of a stunning four-day anti-Morsi revolt that brought out the biggest anti-government rallies Egypt has seen.
"Don't ask me if I am happy. Just look around you at all those people, young and old. They are all happy," said 25-year-old Mohammed Nageh, shouting to be heard in Tahrir. "For the first time, people have really won their liberty."
A statement from Morsi's office's Twitter account quoted Morsi as saying the military's measures "represent a full coup categorically rejected by all the free men of our nation."
The army insisted it is not carrying out a coup, but acting on the will of the people to clear the way for a new leadership. El-Sissi warned that the armed forces, police will deal "decisively" with violence.
Some of Morsi's Islamist backers, tens of thousands of whom took to the streets in recent days, have vowed to fight to the end, although he urged everyone "to adhere to peacefulness and avoid shedding blood of fellow countrymen."
"Down with the rule of the military!" some of them chanted after el-Sissi's speech, reviving a chant used by leftist revolutionaries during the nearly 17 months of direct military rule that followed Mubarak's removal.
El-Sissi warned that the armed forces and police will deal "decisively" with violence.
The army deployed troops, commandos and armored vehicles around the country. In Cairo, they were stationed on bridges over the Nile and at major intersections. They also surrounded rallies being held by Morsi's supporters -- an apparent move to contain them.
After the military's 9:20 p.m. announcement, the Brotherhood's TV station went black. Islamist TV networks that have been accused of inciting violence also went off the air and some of their prominent anchors have been arrested, according to security officials speaking on condition of anonymity because they were not authorized to speak to the media.
Security forces stormed the studio of Al-Jazeera Misr Mubasher and detained the staffers. The station, a branch of Qatari-run Al-Jazeera TV, has maintained a generally pro-Morsi line.
Travel bans were imposed on Morsi and top figures from the Muslim Brotherhood including its chief Mohammed Badie and his powerful deputy Khairat el-Shater. Officials said security forces had surrounded Badie inside a tourist compound where he had been staying in the Mediterranean coastal city of Marsa Matrouh, near the Libyan border.
A security official said Saad el-Katatni, the head of the Freedom and Justice Party, and Rashad Bayoumi, one of two deputies of the Brotherhood's top leader, were arrested early Thursday. The official spoke on condition of anonymity because he was not authorized to talk to the press.
El-Haddad, the Brotherhood party's spokesman, said a list has been drawn up of hundreds of Brotherhood members believed wanted for arrest, including himself.
"We don't know the details. The army is not giving details," he told The Associated Press. "It is a full-fledged coup and it is turning into a bloody one too. They are arresting everybody."
Police shot dead six Islamists who opened fire on Marsa Matrouh's police headquarters as they drove past. Morsi supporters tried to storm a police station in the southern city of Minya, but where battled back by police, killing three, while other Islamists destroyed cars and shops and threw stones at a church in the nearby city of Deir Mawas, while police fired tear gas at them. Police and armed Morsi supporters also battled in the southern city of Assiut, another Islamist stronghold.
Nearly 50 people have been killed in clashes between Morsi supporters and opponents since Sunday.
Morsi took office vowing to move beyond his roots in the Muslim Brotherhood, but his presidency threw the country into deep polarization. Those who took to the streets this week say he lost his electoral legitimacy because he tried to give the Brotherhood and Islamist allies a monopoly on power, pushed through a constitution largely written by his allies and mismanaged the country's multiple crises.
"Now we want a president who would really be the president of all Egyptians and will work for the country," according to Said Shahin, a 19-year-old protester in Tahrir. He fell to the ground to pray as soon as el-Sissi spoke.
Badr, the Tamarod movement spokesman, praised the crowds in the streets saying, they succeeded in "putting your revolution back on track."
"Let's start a new page, a new page based on participation," he wrote on his Twitter account. "Our hand is extended to all."
Morsi and his allies say the opposition never accepted their appeals for dialogue -- seen by opponents as empty gestures -- and that Mubarak loyalists throughout the government sabotaged their attempts to bring change.
Rizk Gamil, a 44-year-old driver, brought his wife to Tahrir to celebrate after el-Sissi announcement. "Today is a day of joy. Today is the day we liberated Egypt from Brotherhood occupation," he said.
A major question now is whether the Brotherhood and other Islamists will push back against the new, military-installed system or can be drawn into it.
Associated Press reporters Tony G. Gabriel and Mariam Rizk contributed to this report.