The Mamluk Reign ended with the Ottoman conquest of Egypt under Sultan Selim I who defeated the Mamluk forces at ar-Raydaniyah. From that time, Egypt became a province under the Ottoman Empire. Selim I left behind him Khair Bey as the sultan's vassal to rule Egypt. Khair Bey kept his court in the Citadel, the ancient residence of the rulers of Egypt.
Under the next sultan, Suliman I, two chambers were created, in which, both the army and the religious authorities were represented to aid the Pasha by their deliberations. These two champers were called the 'Greater Divan' and 'Lesser Divan'. Selim I's and his successors' attempts to extinguish the power and the influence of the Mamelukes in Egypt all went in vain. The Ottoman Turks ruled Egypt from Istanbul through Pashas whose rule did not exceed collecting taxes. The Ottomans relied on the Mamluk army whose ranks continued to expand with mercenary slaves brought in from the Caucasus. During the latter decades of the sixteenth and the early seventeenth centuries, a series of revolts by various elements of the garrison troops broke out.
In 1604, the governor Ibrahim Pasha was murdered by the soldiers, and his head set on the Bab Zuwaylah. During these years, there was also a revival within the Mamluk military structure. By the middle of the seventeenth century, political supremacy had passed to the beys. In 1760, Ali Bey El Kabir assumed the office of Sheikh El Balad (Ruler of the Country). He gained control of the army and allied with Sheikh Daher El Omar in Palestine against the Ottoman Sultan and expelling the Ottoman Wali and announcing Egypt's independence. He issued firmans (decrees) in his own name, redirected the state revenues to his own use, and attempted to recreate the Mamluk Empire by invading Syria. He also managed to extend his influence to Hijaz and Yemen and sent an army under the leadership of Muhammad Bey Abu El-Dahab. In addition, Ali Bey tried to strengthen trade ties with Europe by encouraging trade and attempting to open the Port of Suez to European shipping. Ali Bey ruled only briefly and his successors, especially Muhammad Bey, continued his policies. In 1786, an expedition was sent by the Porte to restore the Ottoman supremacy in Egypt. After the death of Muhammad Bey, there was a struggle upon dominance among the beys. Ibrahim Bey and Murad Bey succeeded in asserting their authority and shared power in Egypt and both continued in power until the French Invasion in 1798.

The French Occupation of Egypt (1799-1802) 

The armies of Napoleon Bonaparte defeated the Mameluke army at Imbabah and Shubra Khit; took Alexandria; and occupied Cairo. In fact, Napoleon wanted to strike a blow to the British Empire, with which France was at war in order to gain control over land and sea routes to the British colony of India. Within a month of entering Egypt, the British navy, under Admiral Nelson, attacked and destroyed the French fleet at Abu Qir Bay in Alexandria. The Ottoman Sultan Selim III sent an army that, although it was defeated by the French, made it clear they were not in Egypt with the complicity of Constantinople.
The people of Cairo rioted against the French. Centered on Al Azhar mosque and led by the 'ulama' (high respected religious figures), the rebellion had a religious as well as a national character. During this period, the populace began to regard the ulama not only as moral but also as political leaders. By that time, the French general Dupuy was killed. Bonaparte and General Jean Baptiste Kléber quickly suppressed this rising; but the stabling of the French cavalry in the mosque of Al-Azhar gave great and permanent offence. In 1799, Napoleon succeeded in invading Syria but failed in taking Acre (in Palestine) and his forces retreated. During Bonaparte's absence from Egypt, Murad Bey and Ibrahim Bey made an attempt to attack Cairo, but he arrived in time and inflicted a crushing defeat on the Turkish army that had landed at Abu Qir, aided by the British fleet that was commanded by Sir Sidney Smith. Few months later, Napoleon, with a very small company, secretly left Egypt to France, leaving his troops behind and General Jean-Baptiste Kléber as his successor. General Kléber was assassinated, leaving the army to General Menou, who claimed to have converted to Islam and declared Egypt a French protectorate.
The occupation was finally terminated by an Anglo-Ottoman invasion force. The French forces in Cairo surrendered on June 18, 1801, and Menou himself surrendered at Alexandria on September 3. By the end of September, the last French forces had left the country. Napoleon's invasion revealed the Middle East as an area of immense strategic importance to the European powers, thus inaugurating the Anglo-French rivalry for influence in the region and bringing the British into the Mediterranean. Napoleon established a style of the French government. He implemented public works projects to clean up and renovate the long-neglected country, clearing blocked canals, cleaning the streets and building bridges. He also introduced new crops and a new system of weights and measures. The task of the 167 scholars, scientists and artists who accompanied him was to investigate every aspect of life in ancient and contemporary Egypt. The publication of "Description de l'Egypte" in 24 volumes became the foundation of modern research into the history, society, and economics of Egypt.