 Egypt remained semi-autonomous under the Mamluks until it was invaded by the French forces of Napoleon Bonaparte in 1798 (see French campaign in Egypt and Syria).After the French were defeated by the British, a power vacuum was created in Egypt, and a three-way power struggle ensued between the Ottoman Turks, Egyptian Mamluks who had ruled Egypt for centuries, and Albanian mercenaries in the service of the Ottomans.After the French were expelled, power was seized in 1805 by Muhammad Ali Pasha, an Albanian military commander of the Ottoman army in Egypt.