Egypt's President Mohamed Morsi sacked his spy chief and two generals on Wednesday after a deadly ambush on soldiers prompted the military to launch unprecedented air strikes on militants in the Sinai.
The government appeared set on regaining control of Sinai, where 16 soldiers were killed in a militant ambush on the weekend which exposed Egypt's weak grip on the lawless peninsula despite a bolstered military presence since last year.
The changes in the military and intelligence ranks came as the army declared tentative victory against the Islamist militants on Wednesday, hours after state television reported 20 militants killed in air strikes.
The campaign to uproot the militants was launched on Tuesday, two days after gunmen ambushed a border guard outpost near Israel's border and killed the 16 soldiers, the military said in a statement.
"Elements from the armed forces and interior ministry supported by the air force began a plan to restore security by pursuing and targeting armed terrorist elements in Sinai, and it has accomplished this task with complete success," it said.
It would continue "continue implementing this plan," it added in a statement, which did not provide details of the operation.
Morsi's spokesman said the president ordered intelligence chief Murad Muwafi to retire, and the replacement of the Republican Guard's chief as well as the head of the military police, Major General Hamdi Badeen.
The spokesman, Yassir Ali, did not connect the changes to the attack, but a senior official close to Morsi told AFP the shuffle was ordered because of the Sinai incident.
He said Morsi wanted Badeen sacked because it bungled a military funeral for the slain soldiers on Tuesday in which protesters tried to assault the Islamist premier, Hisham Qandil.
Morsi also sacked the governor of North Sinai, Abdel Wahab Mabruk.
Earlier, Muwafi had issued a rare public statement defending his agency, saying that it had forewarning of the attack and had relayed it to the "relevant authorities."
He added that the intelligence did not specify where the attack would take place.
Wednesday's reported air strikes in Tumah village -- the first in the peninsula for decades -- came as security forces massed near Rafah on the Gaza border for what they called a decisive confrontation with the militants.
Signup to our newsletter and follow us on Facebook and Twitter!
A senior military official in Sinai confirmed the state television report and said "20 terrorists were killed" in Apache helicopter raids and when soldiers from the 2nd Infantry Division stormed Tumah.
He said the militants were trying to escape when the helicopter targeted their vehicles.
Other security officials in the north of the peninsula reported air strikes near the town of Sheikh Zuwayid, close to the village.
Overnight, unknown assailants attacked four security checkpoints near the town of El-Arish, security officials said. The interior ministry said three policemen were wounded.
The 16 soldiers were killed when the militants raided a border guard base under the cover of mortar fire, and commandeered a military vehicle into neighbouring Israel before they were halted by an Israeli helicopter strike.
Israel had handed over to Egypt six "completely charred" bodies that were in the armoured personnel carrier that was driven into Israel before being destroyed, said a medical official in El-Arish.
The reports of the Egyptian raids in Sinai were welcomed in Israel.
"These extremist organisations can harm the entire Middle East, it is not just against Egypt," Amos Gilad, a senior defence ministry official, told Israeli radio.
The bodies from Sunday's attack have not yet been identified, but security officials blame Bedouin militants and Palestinian Islamists from Gaza.
Sunday's attack presented a challenge to Morsi, whose Muslim Brotherhood has good relations with the Hamas rulers of the Gaza Strip.
Morsi has received both Hamas's chief and its prime minister in Gaza, Ismail Haniya, in visits, along with Palestinian president Mahmud Abbas, and his government had eased border restrictions on Gaza.
After Sunday's attack, Egypt indefinitely closed its Rafah crossing with Gaza, the Palestinian territory's only access to the outside world that is not controlled by Israel.
The enclave has been under a semi-blockade by Israel since Hamas seized it in 2007.
After president Hosni Mubarak's ouster in February 2011, militants stepped up attacks in Sinai, prompting the military, then in charge, to send reinforcements to the peninsula.