CAIRO -- 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.
A statement on the Egyptian presidency's Twitter account quoted Mohammed Morsi as calling military measures "a full coup categorically rejected by all the free men of our nation."
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 to the ousted president, 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."
The deadline on the military's ultimatum to Morsi expired a few hours earlier, with 48 hours passing since the time it was issued.
Giant cheering crowds of Morsi's opponents had gathered in Cairo's Tahrir Square and other locations nationwide, waving flags furiously in expection that the military would act to remove the Islamist.
Before the deadline, the military had already moved to tighten its control on key institutions, putting officers in the newsroom of state TV, in preparation for an almost certain push to remove Morsi.
Morsi, inaugurated a year ago after the 2011 fall of his autocratic predecessor Hosni Mubarak, had repeated his vows not to step down in the face of millions of protesters in the streets in the biggest anti-government rallies the country has seen.
His 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. At least 39 people have been killed in clashes since Sunday, raising fears the crisis could further explode into violence
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."
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 election legitimacy by trying to monopolize power with Islamists -- and that if it takes his army intervention to bring in new leadership and put the country on a more democratic path, so be it.
But at the main pro-Morsi protest in Cairo, a hard-line cleric Magdy Hussein read a statement to the crowds of thousands, saying that any move against Morsi would be considered "a full coup."
"Wake up el-Sissi, Morsi is my president," the crowds chanted outside the Rabia al-Adawiya Moqsue. "We will not bring back the military rule."
"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. 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 television on the banks of the Nile River 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.
The state TV is run by the information minister, a Muslim Brotherhood member put in the post by Morsi, and its coverage had largely been in favor of the government. But already in the past two days, the coverage saw a marked shift, with more balanced reporting showing the anti-Morsi protests along with pro-Morsi ones. State radio has seen a similar shift.
The authoritative, 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 and issued a foreign travel ban on the Islamist group's top leaders.
It said several top Brotherhood leaders have been put under house arrest, though there was no immediate confirmation of which figures it was referring to. It also said arms caches allegedly belonging to the Brotherhood have been located.
Security officials at Cairo's international airport said the travel ban covered among others the Brotherhood's former leader Mahdi Akef and the group's senior official Mohammed el-Beltagi and the leader of the Islamist Wasat party Abou Ela Madi and his deputy Essam Sultan.
The 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. They spoke on condition of anonymity because they were not authorized to speak to the media.
"We will steadfastly and peacefully reject this coup, adhering to our fair stand," el-Beltagi wrote Wednesday on his official Facebook account.
The head of the army, Defense Minister Gen. Abdel-Fattah el-Sissi, held a group meeting 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 the meeting 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.
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.
Massive crowds of anti-Morsi protesters moved back into the main squares of Cairo and other major cities for a fourth straight day. Cairo's central Tahrir Square was a sea of furiously waving Egyptian flags as the throngs waited for an announcement by the military that the deed was done.
The looming showdown follows a night of deadly clashes in Cairo and elsewhere in the country that left at least 23 people dead, most in a single incident near the main Cairo University campus. At least 39 people have died since the protests began on Sunday.
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 statement showed that Morsi and his 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, piled up the pressure on Morsi on Wednesday. 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.
As anti- and pro-Morsi supporters geared up for the fourth consecutive day of mass rallies Wednesday, it was clear that Egypt's crisis has become a struggle over whether a popular uprising can overturn the verdict of the ballot box.
Mahmoud Badr, spokesman for Tamarod, or Rebel -- the youth movement behind the latest wave of protests -- called on anti-Morsi protesters to demonstrate outside three presidential palaces as well as the Cairo headquarters of the Republican Guard, an army branch tasked with protecting the president, his family and presidential palaces. 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 Wednesday.
Morsi's opponents say he has lost his legitimacy through mistakes and power grabs and that their turnout on the streets over the past three days shows the nation has turned against him.
On Tuesday, millions of jubilant, chanting Morsi opponents again filled Cairo's historic Tahrir Square, as well as 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.
On Monday, the military gave Morsi an ultimatum to meet the protesters' demands within 48 hours. If not, the generals' plan would suspend the Islamist-backed constitution, dissolve the Islamist-dominated legislature and set up an interim administration headed by the country's chief justice, the state news agency reported.
The leaking of the military's so-called political "road map" appeared aimed at adding pressure on Morsi by showing the public and the international community that the military has a plan that does not involve a coup.
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.
Morsi's adviser Ayman Ali denied that the U.S. asked Egypt to call early presidential elections and said consultations were continuing to reach national conciliation and resolve the crisis. He did not elaborate.
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.
Associated Press reporters Tony G. Gabriel and Mariam Rizk contributed to this report.