In 1798, Napoleon invaded Egypt, forcing the Porte to redeploy thousands of regulars from the Balkans in order to resist the French. The janissaries in the Pashalik of Belgrade, known as Dahis (), who had been expelled from the region on Selim's orders nearly a decade earlier, were pardoned and allowed to return to Belgrade on the condition that they obey Mustafa Pasha. The détente between the aging governor and the Dahis did not last long. In 1801, Mustafa Pasha was killed by a Dahi assassin.