History of Egypt under the Muhammad Ali dynasty  The history of Egypt under the Muhammad Ali dynasty (1805–1953) spanned the later period of Ottoman Egypt, the Khedivate of Egypt under British patronage, and the nominally independent Sultanate of Egypt and Kingdom of Egypt, ending with the Revolution of 1952 and the formation of the Republic of Egypt. The process of Muhammad Ali's seizure of power was a long three way civil war between the Ottoman Turks, Egyptian Mamluks, and Albanian mercenaries. It lasted from 1803 to 1807 with the Albanian Muhammad Ali Pasha taking control of Egypt in 1805, when the Ottoman Sultan acknowledged his position. Thereafter, Muhammad Ali was the undisputed master of Egypt, and his efforts henceforth were directed primarily to the maintenance of his practical independence. Ottoman-Saudi war in 1811–18 was fought between Egypt under the reign of Muhammad Ali (nominally under Ottoman rule) and the Wahabbis of Najd who had conquered Hejaz from the Ottomans. When Wahabis captured Mecca in 1802, the Ottoman sultan ordered Muhammad Ali of Egypt to start moving against Wahabbis to re-conquer Mecca and return the honour of the Ottoman Empire. Acknowledging the sovereignty of the Ottoman Sultan, and at the commands of the Ottoman Porte, in 1811 Muhammad Ali dispatched an army of 20,000 men (and 2,000 horses) under the command of his son Tusun, a youth of sixteen, against the Saudis in the Ottoman–Saudi War. After a successful advance this force met with a serious repulse at the Battle of Al-Safra, and retreated to Yanbu. In the end of the year Tusun, having received reinforcements, again assumed the offensive and captured Medina after a prolonged siege. He next took Jeddah and Mecca, defeating the Saudi beyond the latter and capturing their general. But some mishaps followed, and Muhammad Ali, who had determined to conduct the war in person, left Egypt in the summer of 1813—leaving his other son Ibrahim in charge of the country. He encountered serious obstacles in Arabia, predominantly stemming from the nature of the country and the harassing mode of warfare adopted by his adversaries, but on the whole his forces proved superior to those of the enemy. He deposed and exiled the Sharif of Mecca and after the death of the Saudi leader Saud he concluded a treaty with Saud's son and successor, Abdullah I in 1815. Following reports that the Turks, whose cause he was upholding in Arabia, were treacherously planning an invasion of Egypt, and hearing of the escape of Napoleon from Elba and fearing danger to Egypt from France or Britain, Muhammad Ali returned to Cairo by way of Kosseir and Kena, reaching the capital on the day of the Battle of Waterloo.