At the time that Ali Pasha was appointed governor in 1803, Egypt had come under the rule and influence of Ottoman Albanian troops originally sent by the Ottoman sultan in 1801 to fight against the French invasion of Ottoman Egypt under Napoleon, which had occurred in 1798. Although successful in ousting the French with significant help from the British, the Albanian troops, led by Muhammad Ali (who would later seize control of Egypt), chose to remain in Egypt and gain influence for themselves. Playing both long-warring factions in Egypt (the Ottomans and the Mamluks) against each other, the Albanians gained power.