Ottoman-appointed Turkish governor of Egypt, Hain Ahmed Pasha, declared himself the Sultan of Egypt and Egypt independent from the Ottoman Empire. He struck his own coins to legitimize his rule, but soon thereafter, Ottoman forces under Pargalı Ibrahim Pasha captured him and executed him, with Ibrahim Pasha assuming the governorship until he found a more permanent replacement, Hadım Süleyman Pasha. Following the defeat of Napoleon I's forces in 1801, Muhammad Ali Pasha seized power, overthrowing the Mamelukes, and declaring himself ruler of Egypt. In 1805, the Ottoman Sultan Selim III reluctantly recognized him as Wāli under Ottoman suzerainty. Muhammad Ali, however, styled himself as Khedive, and though technically a vassal of the Ottoman Empire, governed Egypt as if it were an independent state. Seeking to rival and ultimately supplant the Ottoman Sultan, Muhammad Ali implemented a rapid modernization and militarization program, and expanded Egypt's borders south into Sudan and north into Syria. Eventually, he waged war on the Ottoman Empire with the intention of overthrowing the ruling Osman Dynasty and replacing it with his own. Though the intervention of the Great Powers prevented Muhammad Ali from realizing his grandiose ambitions of becoming sultan himself, obliging Egypt to remain technically part of the Ottoman Empire, Egypt's autonomy survived his death with the Porte recognizing the Muhammad Ali Dynasty as hereditary rulers of the country. Muhammad Ali's grandson, Ismail I, acceded to the Egyptian throne in 1863 and immediately set about achieving his grandfather's aims, though in a less confrontation manner. A combination of growing Egyptian power, deteriorating Ottoman strength, and outright bribery led to Ottoman Sultan Abdulaziz formally recognizing the Egyptian ruler as Khedive in 1867. As Ismail expanded Egypt's borders in Africa, and the Ottoman Empire continued to decay, Ismail believed he was close to realizing formal Egyptian independence, and even contemplated using the opening of the Suez Canal in 1869 to declare himself Sultan of Egypt. He was persuaded otherwise by pressure from the Great Powers, who feared the consequences of further disintegration of Ottoman power. Ultimately, Ismail's reign ended in failure, due to the massive debt his ambitious projects had incurred. European and Ottoman pressure forced his removal in 1879 and replacement by his far more pliant son Tewfik. The subsequent Orabi Revolt resulted in Great Britain invading Egypt in 1882 on the invitation of Khedive Tewfik, and beginning its decades long occupation of the country. Restoration of