But the request by Mr. Morsi that the commander of the military police, Gen. Hamdy Badeen, be replaced, was probably a bitter pill for General Badeen’s colleagues, Mr. Ashour said. Under rules laid out by the military, Mr. Morsi has no power to dismiss senior officers — thus the request for the dismissal.

Though the military police were not accused of any lapses in the attack on the soldiers, General Badeen’s force was implicated in brutal attacks on protesters after the revolution. Some speculated that the army agreed to replace him, as long as Mr. Morsi made no move to dismiss other senior army officers, for example, the chief of military intelligence.

“I think there was some kind of understanding” between Mr. Morsi and the generals concerning the moves, said Mohamed Habib, a former deputy chairman of the Muslim Brotherhood, if only to avoid the president’s being “surprised with any negative reaction.”

Image The army hunted Wednesday for the perpetrators in Sinai. Credit... The New York Times

Mr. Morsi also seemed anxious to use the reshuffle to dampen some criticism of his cabinet, which was seated last week, for its lack of inclusiveness and imagination, relying as it did on longtime state employees. Human rights activists were angered by Mr. Morsi’s decision to appoint a career police official to head the Interior Ministry, an agency rife with complaints of torture and abuse. On Wednesday, he fired two other Interior Ministry officials.

The governor of North Sinai, Sayyid Abdul Wahab Mabrouk, apparently received the news of his firing shortly before a public event, the opening of a police station in the town of Sheik Zowayed on Wednesday afternoon.

The station had been closed since the uprising last year, when it was set on fire. New furniture sat wrapped in plastic. The police chief, Mohamed Suleiman, who said he finally felt brave enough to wear his white uniform in the town, waited to meet visitors.