Muhammad Ali rose to power in Egypt following a long, three-way civil war between the Ottoman Empire, Mamluks who had ruled Egypt for centuries, and Albanian mercenaries in the service of the Ottomans. The conflict ended in victory for the Albanians (from Rumelia) led by Ali.
The struggle occurred following the French invasion of Egypt by Napoleon. After the French were defeated, a power vacuum was created in Egypt. The Mamluks had governed Egypt before the French invasion and still retained power in the region. However, Egypt was officially a part of the Ottoman Empire and many Ottoman troops who had been sent to evict the French were still present.