The Ayyubid dynasty (Arabic: الأيوبيون al-ʾAyyūbiyyūn) was a Muslim dynasty of Kurdish origin, founded by Saladin and centered in Egypt. The dynasty ruled much of the Middle East during the 12th and 13th centuries CE. The Ayyubid family, under the brothers Ayyub and Shirkuh, originally served as soldiers for the Zengids until they supplanted them under Saladin, Ayyub's son. In 1174, Saladin proclaimed himself Sultan following the death of Nur al-Din. The Ayyubids spent the next decade launching conquests throughout the region and by 1183, the territories under their control included Egypt, Syria, northern Mesopotamia, Hejaz, Yemen, and the North African coast up to the borders of modern-day Tunisia. Most of the Kingdom of Jerusalem and beyond Jordan River fell to Saladin after his victory at the Battle of Hattin in 1187. However, the Crusaders regained control of Palestine's coastline in the 1190s.
After the death of Saladin, his sons contested control over the sultanate, but Saladin's brother al-Adil eventually established himself as Sultan in 1200. In the 1230s, the Ayyubid rulers of Syria attempted to assert their independence from Egypt and remained divided until Egyptian Sultan as-Salih Ayyub restored Ayyubid unity by taking over most of Syria, excluding Aleppo, by 1247. By then, local Muslim dynasties had driven out the Ayyubids from Yemen, the Hejaz, and parts of Mesopotamia. After repelling a Crusader invasion of the Nile Delta, as-Salih Ayyub's Mamluk generals overthrew al-Mu'azzam Turanshah who succeeded Ayyub as Sultan after his death in 1250. This effectively ended Ayyubid power in Egypt and a number of attempts by the rulers of Syria, led by an-Nasir Yusuf of Aleppo, to recover it failed. In 1260, the Mongols sacked Aleppo and wrested control of what remained of the Ayyubid territories soon after. The Mamluks, who forced out the Mongols after the destruction of the Ayyubid dynasty, maintained the Ayyubid principality of Hama until deposing its last ruler in 1341.
During their relatively short tenure, the Ayyubids ushered in an era of economic prosperity in the lands they ruled and the facilities and patronage provided by the Ayyubids led to a resurgence in intellectual activity in the Islamic world. This period was also marked by an Ayyubid process of vigorously strengthening Sunni Muslim dominance in the region by constructing numerous madrasas (schools) in their major cities.