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. The power vacuum caused by his murder resulted in a period of infighting between the Dahis that would last until 1802. By this time, four senior Dahi commanders emerged triumphant and agreed to share power within the Pashalik. The Serbs were stripped of the privileges that they had been granted under Mustafa Pasha. Dahi bands roamed the countryside, killing peasants, looting property and setting homes on fire. Thousands of villagers were displaced and forced to flee into the mountains, where over the next several years, the able-bodied men formed "ad hoc" guerrilla bands.