CAIRO — Egypt carried out a sweeping reshuffle of its security forces, removing a dozen senior police and military officials from critical posts just a week after an ambush by militants killed at least 16 policemen in the desert outside Cairo.

The brief police and military statements that announced the move late on Saturday did not give a reason for the shake-up.

But Egyptian security officials said the reorganization was prompted by the devastating attack, which targeted a police convoy inside the country’s western desert on Oct. 20. The security officials declined to be named because they were not authorized to discuss the matter publicly.

Saturday’s shake-up included the dismissal of Mahmoud Hegazy, the military chief of staff; 11 police generals, including the security chief of Giza, the area where the attack occurred; and the head of the National Security Agency, the police’s intelligence division.