Mohammad Morsi dismissed Field Marshal Hussein Tantawi as defence minister and head of the Supreme Council of the Armed Forces, the body that removed the former dictator Hosni Mubarak from power after the popular uprising last year.
In a clear signal that the balance of power was shifting away from the generals, Mr Morsi also issued a decree cancelling an army declaration that restricted the powers of the presidency.
Mr Morsi, who was elected in June and is a member of the Muslim Brotherhood, appointed Mahmoud Mekki, a judge with an independent reputation, as vice-president and promoted Lt Gen Abdel Fattah al-Sissi to the post of defence minister.
Field Marshal Tantawi, 76, acted as Egypt's de facto head of state for 17 months after Mubarak was ousted in response to the Arab Spring demonstrations in Cairo. Before that he had headed the defence ministry for 20 years.
"Field Marshal Hussein Tantawi has been transferred into retirement from today," said Yasser Ali, a presidential spokesman. "The decision was sovereign by the president to pump new blood into the military establishment for the sake of developing the new, modern state."
The elected leadership believes Egypt has been in limbo after military decrees left the presidential role weakened and a constitutional convention failed to agree on an alternative system.
In his decree yesterday, Mr Morsi changed the interim constitution to exclude the military from public policy, budgetary decisions and the assembly that is drafting a permanent constitution. Officials from the Muslim Brotherhood, which has contested the army's role in Egypt for decades, said Mr Morsi had to show the authority of the presidency. "Given the circumstances, this is the right time to make changes in the military institution," said Mourad Ali, a senior official with the Brotherhood's Freedom and Justice Party. "He is a strong president, and he is exercising his authority."
Islamists scored a crushing victory in Egyptian parliamentary elections last year, with the Muslim Brotherhood dominating the legislative assembly.
It has had to overcome a determined rearguard by the military and its allies in the judiciary, including an attempt to dissolve the parliament.
The Brotherhood was quick to mobilise its supporters last night for a show of popular backing in Cairo's Tahrir Square, but there were signs that the army leadership had accepted the presidential orders. "The decision was based on consultation with the field marshal and the rest of the military council," said Gen Mohamed el-Assar, the new deputy defence minister.
While some of the more ebullient followers of the Muslim Brotherhood hailed the moves as "soft coup" by Mr Morsi, more sober commentators said the developments could represent the start of a controlled exit for the military.
"It is safe to assume Morsi couldn't have done this without support from within the army," said Abdel-Rahman Hussein, an analyst. "There's always been talk that Tantawi is not popular within the ranks."
Increasing violence on the Sinai Peninsula helped to give Mr Morsi the impetus to act against the army, which is involved in its largest operation in the area since the Yom Kippur war in 1973.
Despite the urgings of Israel and others, it had allowed Islamist insurgents to expand in the area. It was only when 16 border guards were killed eight days ago that the military finally took action.
Insurgents' camps have since been raided just 10 miles from the Israeli border and fighting yesterday was reported to have killed another six.