Watch live coverage from Tahrir Square

UPDATE 11:49 p.m. ET: The latest information via the Associated Press:

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.

UPDATE 9:15 p.m. ET: The New York Times reports:

By the end of the night, Mr. Morsi had been taken into custody and blocked from all communications, one of his advisers said. Egyptian security forces had arrested at least 38 senior leaders of the Muslim Brotherhood, including Saad el-Katatni, the chief of the group’s political party, and others were being rounded up as well, security officials said. No immediate reasons were given for the detentions.

UPDATE 8:48 p.m. ET: Clashes Tuesday quickly erupted in several provincial cities when Islamists opened fire on police, with at least nine killed in the battles, security officials said.

Moments after military chief Gen. Abdel-Fattah el-Sissi spoke, a defiant 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.

UPDATE 8:00 p.m. ET: President Barack Obama urged Egypt’s military Wednesday to hand back control to a democratic, civilian government without delay, but stopped short of calling the ouster of President Mohammed Morsi a coup d’etat.

Read Obama’s full statement here.

UPDATE 7:06 p.m. ET: CAIRO (AP) — A security official says the head of the Muslim Brotherhood political party and the Brotherhood’s deputy chief have been arrested.

The 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, in connection with an escape from prison during the 2011 uprising against autocrat Hosni Mubarak.

The official spoke on condition of anonymity because he was not authorized to talk to the press.

The arrest came hours after the head of the armed forces ousted Egypt’s first democratically elected President Mohammed Morsi, of the Brotherhood, who is also wanted in the case. More than 30 Brotherhood members escaped from prison during in January 2011.

UPDATE 4:57 p.m. ET: A U.S. official tells the AP all nonessential diplomats and embassy families are leaving Egypt.

UPDATE 4:02 p.m. ET: Morsi has issued these tweets from the Egyptian presidency Twitter account:

Pres. Morsy: Measures announced by Armed Forces leadership represent a full coup categorically rejected by all the free men of our nation
Military Coup in Egypt Removes Morsi From Power
@EgyPresidency
Egyptian Presidency
Pres. Morsy: Armed Forces announcement is rejected by all free men who struggled for a civil democratic Egypt.
Military Coup in Egypt Removes Morsi From Power
@EgyPresidency
Egyptian Presidency
Pres. Morsy urges civilians and military members to uphold the law & the Constitution not to accept that coup which turns #Egypt backwards
Military Coup in Egypt Removes Morsi From Power
@EgyPresidency
Egyptian Presidency
Pres. Morsy urges everyone to adhere to peacefulness and avoid shedding blood of fellow countrymen.
Military Coup in Egypt Removes Morsi From Power
@EgyPresidency
Egyptian Presidency

UPDATE 3:35 p.m. ET: CAIRO (AP) — Egypt’s military has ousted the nation’s Islamist president, replacing him with the chief justice of the Supreme Constitutional Court, calling for early presidential election and suspending the Islamist-backed constitution.

Army chief Abdel-Fattah el-Sissi, in a televised address to the nation on Wednesday, said a government of technocrats will be appointed to run the country during a transition period he did not specify.

An aide of ousted President Mohammed Morsi, Ayman Ali, said the former leader has been moved to an undisclosed location. He gave no details.

Cheers erupted among millions of protesters nationwide who were demanding Morsi’s ouster. Fireworks lit the Cairo night sky. Morsi supporters elsewhere in the city shouted “No to military rule.”

Military Coup in Egypt Removes Morsi From Power

A military helicopter files over the presidential palace as opponents of Egypt’s Islamist President Mohammed Morsi celebrate, in Cairo, Egypt, Wednesday, July 3, 2013. (AP)

Earlier story below:

CAIRO (TheBlaze/AP) — Egypt’s military moved to tighten its control of key institutions Wednesday, sending troops backed with armored vehicles to the heart of Cairo and slapping a travel ban on President Mohammed Morsi and top allies in preparation for an almost certain push to remove the Islamist president with the expiration of an afternoon deadline.

Just before the military’s deadline expired, Morsi repeated a vow not to step down, and one of his top advisers decried that Egypt is experiencing a military coup.

An adviser told CNN that “under no circumstances” would they accept the coup.

Military Coup in Egypt Removes Morsi From Power

Opponents of Islamist President Mohammed Morsi flash victory signs and wave national flags in Cairo, Egypt, Wednesday, July 3, 2013. (AP)

Egyptian media had reported earlier Wednesday that Morsi had been placed under house arrest, which his aides denied.

For the second time in 2 1/2 years of political upheaval, the powerful army appears to be positioned to remove the country’s leader. But this time, it would be ousting a democratically elected president, the first in Egypt’s history – making its move potentially explosive.

Soon after the deadline passed, a military helicopter circled over the anti-Morsi crowds in Cairo’s central Tahrir Square, which was transformed into a sea of furiously waving Egyptian flags. “Leave, leave,” they chanted to Morsi, electrified as they waited to hear of an army move. After nightfall, fireworks went off and green lasers flashed over the crowd.

Millions were in the main squares of major cities nationwide, demanding Morsi’s removal, in the fourth day of the biggest anti-government rallies the country has seen, surpassing even those in the uprising that ousted against his autocratic predecessor Hosni Mubarak.

The troops, including commandos and in full combat gear, deployed just as darkness fell across much of the Egyptian capital at key facilities, on bridges over the Nile River and at major intersections. They also surrounded rallies being held by Morsi’s supporters – an apparent move to keep them contained if a final move on the president is made.

Military Coup in Egypt Removes Morsi From Power

Opponents of Egypt’s Islamist President Mohammed Morsi shout slogans and wave national flags as they celebrate in Tahrir Square in Cairo, Egypt, Wednesday, July 3, 2013. Airport officials say a travel ban has been issued against the embattled president and the leader of the Muslim Brotherhood. The officials said Wednesday that the travel ban on Morsi has to do with his escape from prison with more than 30 other Muslim Brotherhood during the 2011 uprising against autocrat Hosni Mubarak. (AP)

Morsi’s Islamist supporters have vowed to resist what they call a coup against democracy, and have also taken to the streets by the tens of thousands. Still, at the Rabia al-Adawiya Mosque, their main rally, some sought to depict the soldiers sealing off the nearby streets as on their side. They handed them flags, took pictures with them and chanted, “The army and people are one hand.”

At least 39 people have been killed in clashes since Sunday, raising fears of further bloodshed. Egypt was mostly peaceful on Wednesday, with the only report of violence coming from the Nile Delta city of Kafr el-Sheikh where supporters and opponents of Morsi clashed. At least 200 people were injured there, but no fatalities.

Earlier in the day, the head of the army, Defense Minister Gen. Abdel-Fattah el-Sissi, met with leading reform advocate Mohammed ElBaradei, Egypt’s top Muslim cleric – Al-Azhar Sheik Ahmed el-Tayeb – and Coptic Pope Tawadros II to discuss its political road map, a spokesman for the senior opposition National Democratic Front, Khaled Daoud, said on state TV.

Also attending were a representative of the new youth movement behind this week’s protests and some members of the ultraconservative Salafi movements, a Defense Ministry official told The Associated Press. The official spoke on condition of anonymity because he was not authorized to speak to the media.

A travel ban was put on Morsi and the head of his Muslim Brotherhood, Mohammed Badie, as well as Badie’s deputy Khairat el-Shater, according to officials at the airport, who spoke on condition of anonymity because they were not authorized to talk to the press.

Also banned from leaving the country were the Brotherhood’s former leader Mahdi Akef, senior Brotherhood figure Mohammed el-Beltagi, a major Salafi preacher close to the Brotherhood Safwat Hegazy and the leader of the Islamist Wasat party Abou Ela Madi and his deputy Essam Sultan.

Military Coup in Egypt Removes Morsi From Power

Getty Images

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.

The free electing of a president had been one of the aspirations of the 2011 revolt that toppled Mubarak. Morsi’s opponents say they want to remove a president who has lost his legitimacy by trying to monopolize power with Islamists – even if it takes army intervention to bring in new leadership and put the country on a more democratic path.

But on his Facebook page, Morsi’s top foreign policy adviser Essam al-Haddad wrote, “For the sake of Egypt and for historical accuracy, let’s call what is happening by its real name: Military coup.”

At the main pro-Morsi rally in Cairo, thousands of his Islamist supporters chanted, “Wake up el-Sissi, Morsi is my president.”

“We will not bring back the military rule,” they chanted outside the Rabia al-Adawiya Mosque. “Will not happen, will not happen,” they shouted.

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. Under a plan leaked to state media, the military would install a new interim leadership, the Islamist-backed constitution suspended and the Islamist-dominated parliament dissolved.

But on Wednesday it clearly was positioning itself to maintain control during any unrest sparked by a move on Morsi.

The military beefed up its presence inside the mammoth headquarters of state TV on the banks of the Nile in central Cairo. Crack troops were deployed in news production areas. Officers from the army’s media department moved inside the newsroom and were monitoring output, though not yet interfering, staffers said, speaking on condition of anonymity because they were not authorized to talk about the arrangements.

State TV is run by the information minister, a Muslim Brotherhood member appointed by Morsi, and its coverage had largely been in favor of the government. But in the past two days, the coverage saw a marked shift, with more balanced reporting showing anti-Morsi protests along with those supporting him. State radio has seen a similar shift.

The state-run Al-Ahram newspaper – which also seemed to be following a military line – reported that the military had placed several leaders of Morsi’s Muslim Brotherhood under surveillance.

Airport officials said screening departing passengers has been tightened to ensure leaders of the Brotherhood and other Islamist groups don’t slip out with the help of sympathetic airport employees.

In a speech late Tuesday night, Morsi vowed not to step down and pledged to defend his legitimacy with his life in the face of the massive street protests.

Morsi demanded that the powerful armed forces withdraw their ultimatum, saying he rejected all “dictates” – from home or abroad. The army said if no agreement is reached between Morsi and the opposition it would intervene to implement a political road map of its own.

In his emotional, 46-minute address aired live to the nation late Tuesday, the Islamist leader accused loyalists of his ousted autocratic predecessor Hosni Mubarak of exploiting the wave of protests to topple his regime and thwart democracy.

“There is no substitute for legitimacy,” said Morsi, at times angrily raising his voice, thrusting his fist in the air and pounding the podium. He warned that electoral and constitutional legitimacy “is the only guarantee against violence.”

The speech showed that Morsi and the Muslim Brotherhood are prepared to run the risk of challenging the army. It also entrenches the lines of confrontation between his Islamist supporters and Egyptians angry over what they see as his efforts to impose control through the Brotherhood and his failures to deal with the country’s multiple problems.

The Interior Ministry, in charge of the police, increased the pressure on Morsi. It pledged in a statement to stand by and protect the protesters against violence. “We are all the Egyptians, and at the face of the military, we are standing,” they screamed.

Mahmoud Badr, spokesman for Tamarod, or Rebel – the youth movement behind the latest rallies – called on anti-Morsi protesters to demonstrate outside three presidential palaces as well as the Cairo headquarters of the Republican Guard, an army branch that protects the president, his family and their residences and offices. Morsi is thought to have been working at the Republican Guard headquarters since the start of the protests.

Badr also called on the army to place Morsi under arrest for his alleged incitement to civil war.

“Today is the day of decisiveness,” Badr said at a news conference.

Morsi’s opponents say he has lost his legitimacy through mistakes and power grabs, and that their turnout on the streets shows the nation has turned against him.

On Tuesday, millions of jubilant, chanting Morsi opponents again filled Tahrir Square and avenues adjacent to two presidential palaces in the capital, and main squares in cities nationwide. After Morsi’s speech, they erupted in indignation, banging metal fences to raise a din, some raising their shoes in the air in a show of contempt. “Leave, leave,” they chanted.

The president’s supporters also moved out in increased marches in Cairo and other cities, and stepped up warnings that it will take bloodshed to dislodge him. While Morsi has stuck to a stance that he is defending democracy in Egypt, many of his Islamist backers have presented the fight as one to protect Islam.

Fearing that Washington’s most important Arab ally would descend into chaos, U.S. officials said they are urging Morsi to take immediate steps to address opposition grievances, telling the protesters to remain peaceful and reminding the army that a coup could have consequences for the massive American military aid package it receives. The officials spoke on condition of anonymity because they were not authorized to speak publicly.

The army has insisted it has no intention to take power. But the reported road map showed it was ready to replace Morsi and make a sweeping change in the ramshackle political structure that has evolved since Mubarak’s fall in February 2011.

The constitution and domination of the legislature after elections held in late 2011-early 2012 are two of the Islamists’ and Brotherhood’s most valued victories – along with Morsi’s election last year.

This post has been updated.