Egypt's Islamist President Mohammed Morsi on Sunday ordered the surprise retirement of his powerful defence minister and scrapped a constitutional document which handed sweeping powers to the military.
In a move that drew thousands of Islamist supporters to Cairo's Tahrir Square in celebration, Morsi effectively dismissed Field Marshal Hussein Tantawi, who ruled Egypt for more than a year after the revolution that toppled former president Hosni Mubarak.
The president also scrapped a key constitutional document which gave the military legislative powers and other prerogatives, his spokesman Yasser Ali said.
The surprise announcements marked a new twist in the uneasy relationship between Morsi and the army, testing the balance of power between the first civilian president in Egypt's history and a military that had moved to limit his power.
In a speech at Cairo's al-Azhar mosque after the announcement, the president defended himself against claims he wanted to marginalise the army.
"I only wish them the best. I want them to devote themselves to a mission, the protection of the nation," he said.
"I never intended, through my decisions, to marginalise or be unjust toward anyone, but rather to act so that we advance toward a better future, with a new generation, long-awaited new blood.
"I did not intend to embarrass institutions," he added, saying he had "the interest of the country in mind."
Thousands of Islamist supporters celebrated the announcement Sunday night in the Cairo square that played home to the protests that ousted Mubarak.
"The people support the president's decision," the crowd chanted.
Others mocked Tantawi's departure, presented officially as a retirement.
"Marshal, tell the truth, did Morsi fire you?" they said.
The veteran army leader -- who had served as Mubarak's defence minister for two decades and headed the country after the strongman's overthrow, until he handed power to Morsi on June 30 -- was replaced by Abdel Fattah al-Sissi.
Armed forces chief of staff Sami Anan was also retired, state television said, a week after a deadly attack on the Egyptian military in the Sinai prompted an unprecedented military campaign in the lawless peninsula.
Tantawi and Anan, both recipients of the Greatest Nile Collar, Egypt's most prestigious award, had been retained as presidential advisors.
Morsi also amended the interim constitution to deny the military any role in public policy-making, the budget and legislation, and the right to pick a constituent assembly drafting a permanent constitution for post-Mubarak Egypt.
"The president has decided to annul the constitutional declaration adopted on June 17" by the Supreme Council of the Armed Forces, headed by Tantawi, his spokesman said.
"Given the circumstances, this is the right time to make changes in the military institution," said Mourad Ali, a senior official with the Muslim Brotherhood's Freedom and Justice Party, which fielded Morsi in a May-June presidential election.
"He is a strong president, and he is exercising his authority," Ali said.
An unnamed military source told Egypt's official news agency MENA that Morsi had made the decisions "after consultations with the armed forces", denying that military top brass were unhappy about the changes.
Morsi, an Islamist who rose through the ranks of the Muslim Brotherhood before his election triumph, also decided to appoint a vice president.
He appointed judge Mahmud Mekki as his deputy, MENA reported, making him only the second vice president to be named in Egypt in 30 years.
Mubarak, who was ousted in February 2011, named his spy chief Omar Suleiman as vice president just days before being forced to step down, after having resisted for three decades from naming a likely successor.
Sunday's moves were the latest in a series of major decisions taken by Morsi since the deadly attack on troops in the Sinai peninsula on August 5.
Last Wednesday, the president ordered spy chief Muraf Muwafi to retire in a reshuffle of military and intelligence ranks after the attack which killed 16 soldiers near Egypt's borders with Israel and the Gaza Strip.
He also sacked the governor of North Sinai, Abdel Wahab Mabruk.
And the head of military police, Hamdi Badeen, was replaced because he was deemed to have failed to secure the funeral for the slain soldiers, during which some protesters tried to assault Prime Minister Hisham Qandil.
Islamists scored a crushing victory in Egyptian parliamentary elections that were held in three stages from November last year, with the Muslim Brotherhood dominating the lower house.
But the military dissolved parliament in May after the Supreme Constitutional Court ruled that certain articles in the law governing the parliamentary polls were invalid, annulling the Islamist-led house, a decision rejected by Morsi.