Egyptian President Mohammed Mursi has said his move to order the retirement of two of the country’s top generals was for “the benefit of this nation”.
He was speaking after replacing the powerful head of the armed forces, Field Marshal Mohamad Hussein Tantawi, and Chief of staff Sami Annan.
Mr Mursi also said a constitutional declaration aimed at curbing presidential powers had been cancelled.
Mr Mursi, who was elected in June, is linked to the Muslim Brotherhood.
Relations between Islamists and the military have been increasingly tense since the fall of President Hosni Mubarak last year amid mass street protests.
“The decisions I took today were not meant ever to target certain persons, nor did I intend to embarrass institutions, nor was my aim to narrow freedoms,” Mr Mursi said during a speech to mark the Muslim fasting month of Ramadan.
As he took office it seemed President Mohammed Mursi would be governing within narrow limits set by Egypt’s generals – who had exercised power behind the throne for decades and then exercised it directly in the months since the fall of Hosni Mubarak.
But it is possible Mr Mursi’s opponents may have underestimated him.
Egypt’s army was unprepared for a recent attack on a security base in the Sinai desert by Islamic militants in which 16 soldiers died.
Mr Mursi appears to be seizing on that failure – which shocked ordinary Egyptians – to move against two key members of the high command.
It may be that the move has been co-ordinated secretly with other influential generals behind the scenes but for now, no-one can be sure.
“I did not mean to send a negative message about anyone, but my aim was the benefit of this nation and its people,” he said.
The president also praised the armed forces, saying they would now focus “on the holy mission of protecting the nation”.
It was announced earlier that a career army officer, Gen Abdel-Fattah al-Sisi, would replace Field Marshal Tantawi as both armed forces chief and defence minister.
Field Marshal Tantawi, 76, has not yet indicated whether he accepts the moves.
However Gen Mohamed el-Assar, a member of the Supreme Council of the Armed Forces (Scaf), told Reuters news agency the decision had been “based on consultation with the field marshal, and the rest of the military council”.
A presidential spokesman said Gen Annan and Field Marshal Tantawi had been appointed as presidential advisers and were given Egypt’s highest state honour, the Grand Collar of the Nile.
BBC Middle East correspondent Kevin Connolly says the dismissal of senior military officers will be seen by Egyptians as a decisive move in a struggle for real power between the country’s newly elected politicians and the generals who have exercised power for many years.
As head of Scaf, Field Marshal Tantawi became Egypt’s interim ruler after President Mubarak was ousted following last year’s mass protests.
Under the interim constitutional declaration issued by Scaf before Mr Mursi was sworn in, the president could not rule on matters related to the military – including appointing its leaders.
The council also dissolved parliament, which is dominated by the Muslim Brotherhood.
Tensions between the presidency and Scaf were further exacerbated after Islamist militants in the Sinai peninsula killed 16 border guards last week, in a raid that embarrassed the military.
The president, whose own Brotherhood movement renounced violence long ago, sacked Egypt’s intelligence chief and two senior generals following the attack.
Mr Mursi resigned from his positions within the Brotherhood, including his role as chairman of its Freedom and Justice Party (FJP), when he won the presidential election in June.