He was a military commander in an Albanian Ottoman force sent to recover Egypt from a French occupation under Napoleon. Following Napoleon's withdrawal, Muhammad Ali rose to power through a series of political maneuvers, and in 1805 he was named "Wāli" (viceroy) of Egypt and gained the rank of Pasha.