CAIRO — 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 in cities around the country erupted in delirious scenes of joy 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.’’
‘‘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 protester Mohammed Nageh, shouting to heard at Tahrir.
‘‘For the first time, people have really won their liberty.’’
Fearing a violent reaction by Morsi’s Islamist supporters, the military sent troops and armored vehicles into streets of Cairo and elsewhere, surrounding Islamist rallies. The head of the political wing of Morsi’s Muslim Brotherhood was arrested.
Clashes quickly erupted in several provincial cities when Islamists opened fire on police, with at least nine killed in the battles, security officials said.
The U.S. has raised the threat level in its travel advisory to Egypt, warning citizens to defer visits and advising Americans there to leave.
The army’s move is the second time in Egypt’s 2 ½ years of turmoil that it has forced out the country’s leader. In the first, it pushed out autocrat Hosni Mubarak after the massive uprising against its rule.
Its new move came after a stunning four-day anti-Morsi revolt that brought protests even larger than those of 2011, fueled by public anger 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.
This time, however, its removal of an elected figure could be more explosive. Beyond fears over violence, even some protesters are concerned whether an army-installed administration can lead to real democracy.
In Washington, President Barack Obama urged Egypt’s military to ‘‘move quickly’’ to return authority to an elected civilian government. 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.
In conversations, senior Egyptian military officers assured U.S. Defense Secretary Chuck Hagel and Gen. Martin Dempsey, chairman of the Joint Chiefs of Staff,they would put a civilian government in place quickly, U.S. officials said. They spoke on condition of anonymity because they were not authorized to speak by name about the private conversations.
Moments after military chief Gen. Abdel-Fattah el-Sissi spoke, Morsi said in a statement on the Egyptian president’s office’s Twitter account that the military’s measures ‘‘represent a full coup categorically rejected by all the free men of our nation,’’ while urging ‘‘everyone to adhere to peacefulness and avoid shedding blood of fellow countrymen.’’
Morsi has insisted his legitimacy as an elected president must not be violated or Egypt could be thrown in to violence. Some of his Islamist backers, tens of thousands of whom took to the streets in recent days, have vowed to fight to the end — to defend both the legitimacy of the vote and their ambitions to bring Islamist rule to Egypt.
‘‘Down with military rule. Revolution, Islamic revolution, against el-Sissi and the thugs,’’ the crowd of thousands chanted at the main pro-Morsi rally in Cairo after the army announcement.
The army has insisted it is not carrying out a coup, but acting on the will of the people to clear the way for a new leadership.
In his speech, Gen. el-Sissi said the chief justice of the Supreme Constitutional Court, Adly Mansour, would step in as interim president until new elections are held. A government of technocrats would be formed with ‘‘full powers’’ to run the country.
Mansour, who was appointed to the court by Mubarak but elevated to the chief justice post by Morsi, will be sworn in on Thursday by judges of his court.
El-Sissi, the defense minister appointed by Morsi, 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. He did not say whether a referendum would be held to ratify the changes, as customary.
El-Sissi spoke while flanked by the country’s top Muslim and Christian clerics as well as pro-reform leader Mohammed ElBaradei and two representatives of Tamarod, or Rebel, the youth opposition movement that engineered the latest wave of protests with a petition campaign that collected more than 22 million signatures of Egyptians who want Morsi to step down.
‘‘I call on all of you to stay in the squares to protect what we have won,’’ one of the two Tamarod members, Mahmoud Badr, said in televised comments.
‘‘I hope this 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,’’ said ElBaradei, a Nobel Peace Laureate and the former head of the U.N. nuclear watchdog.
Seeking to avert a destabilizing backlash, el-Sissi warned that the armed forces, police will deal ‘‘decisively’’ with violence.
The military also took firm moves on the ground.
After the 9:20 p.m., the Brotherhood’s TV station went blank. Islamist TV networks that have been accused of inciting violence also went off the air and some of their prominent anchormen have been arrested, according to security officials speaking on condition of anonymity because they were not authorized to speak to the media.
Shortly before el-Sissi went on the air, troops, commandos and armored vehicles deployed in cities around the country. In Cairo, they stationed on bridges over the Nile River and at major intersections. They also surrounded rallies being held by Morsi’s supporters — an apparent move to contain them.
Police arrested one of the Brotherhood’s two deputy chiefs, Rashad Bayoumi, and the Saad el-Katatni, the head of the Brotherhood’s political arm, the Freedom and Justice Party, were arrested, security officials said.
Travel bans were imposed on Morsi and top figures from his Muslim Brotherhood including its chief Mohammed Badie and his powerful deputy Khairat el-Shater. Security 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.
Clashes erupted in several cities after el-Sissi announced Morsi’s removal, according to security officials, who spoke on condition of anonymity because they were not authorized to talk to the press.
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. Pollice and armed Morsi supporters also battled in the southern city of Assiut, another Islamist stronghold.
At least 39 people have been killed in clashes between Morsi supporters and opponents since Sunday.
Elected with 51.7 percent of the vote in last year’s presidential election, 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,’’ Said Shahin, a 19-year-old protester in Tahrir, said, falling to the ground to pray as soon as el-Sissi spoke.
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.
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.
The military had issued an ultimatum on Monday giving Morsi 48 hours to find some solution with its opponents. Any deal, however, was a near impossibility, making it inevitable the military would move.
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.
Earlier in the day, the head of the Brotherhood’s political wing, the Freedom and Justice Party, boycotted a meeting called by el-Sissi to discuss the army’s road map. The meeting was attended by ElBaradei, Egypt’s top Muslim cleric — Al-Azhar Sheik Ahmed el-Tayeb — and Coptic Pope Tawadros II, the Tamarod representatives and some members of the ultraconservative Salafi movements.
‘‘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.Material from the New York Times was used in this report.Associated Press reporters Tony G. Gabriel, Mariam Rizk and Brian Rohan contributed to this report.