Egyptian President Mohamed Morsi ordered spy chief Murad Muwafi on Wednesday to retire in a shuffle of military and intelligence ranks after the deadliest militant attack on troops in decades.
The decision extended to Abdel Wahab Mabruk, the governor of North Sinai where a weekend attack that killed 16 soldiers took place.
Morsi also ordered Defence Minister Field Marshal Hussein Tantawi to find a new head for the military police, his spokesman Yassir Ali said in a televised statement.
Ali did not say if the attacks prompted the changes, but a senior official close to Morsi said he decided to sack the generals because of the attack, which led to air strikes against the militants.
Hamdi Badeen, the head of military police, was replaced because he failed to secure the funeral for the slain soldiers, with some protesters trying to assault Prime Minister Hisham Qandil.
Signup to our newsletter and follow us on Facebook and Twitter!
"The prime minister was subjected to an insult. It was unacceptable," said the official on condition of anonymity because of the subject's sensitivity.
Morsi appointed Mohammed Rafaat Abdel Wahad Shehata as the interim head of General Intelligence.
Earlier on Wednesday, Muwafi, himself a former governor of North Sinai, issued a rare public statement saying his agency had forewarned of the weekend attack.
But he said the intelligence did not specify where the attack would take place and he had passed it on to the "relevant authorities," adding that his powerful agency's role was only to collect information.
Morsi is thought likely to have reached the decisions with the military top command, which ruled the country between president Hosni Mubarak's ouster in February 2011 and Morsi's inauguration as his successor in June.