section_path: History/Apogee and decline under the Mamluks
section_name: Apogee and decline under the Mamluks
paragraph_text: Apogee and decline under the Mamluks
  
  In 1250, during the Seventh Crusade, the Ayyubid dynasty had a crisis with the death of al-Salih and power transitioned instead to the Mamluks, partly with the help of al-Salih's wife, Shajar ad-Durr, who ruled for a brief period around this time. Mamluks were soldiers who were purchased as young slaves and raised to serve in the sultan's army. Between 1250 and 1517 the throne of the Mamluk Sultanate passed from one mamluk to another in a system of succession that was generally non-hereditary, but also frequently violent and chaotic. The Mamluk Empire nonetheless became a major power in the region and was responsible for repelling the advance of the Mongols (most famously at the Battle of Ain Jalut in 1260) and for eliminating the last Crusader states in the Levant.
  
  Despite their military character, the Mamluks were also prolific builders and left a rich architectural legacy throughout Cairo. Continuing a practice started by the Ayyubids, much of the land occupied by former Fatimid palaces was sold and replaced by newer buildings, becoming a prestigious site for the construction of Mamluk religious and funerary complexes. Construction projects initiated by the Mamluks pushed the city outward while also bringing new infrastructure to the centre of the city. Meanwhile, Cairo flourished as a centre of Islamic scholarship and a crossroads on the spice trade route among the civilisations in Afro-Eurasia. Under the reign of the Mamluk sultan al-Nasir Muhammad (1293–1341, with interregnums), Cairo reached its apogee in terms of population and wealth. By 1340, Cairo had a population of close to half a million, making it the largest city west of China.
  
  Multi-story buildings occupied by rental apartments, known as a rab' (plural ribā' or urbu), became common in the Mamluk period and continued to be a feature of the city's housing during the later Ottoman period. These apartments were often laid out as multi-story duplexes or triplexes. They were sometimes attached to caravanserais, where the two lower floors were for commercial and storage purposes and the multiple stories above them were rented out to tenants. The oldest partially-preserved example of this type of structure is the Wikala of Amir Qawsun, built before 1341. Residential buildings were in turn organized into close-knit neighbourhoods called a harat, which in many cases had gates that could be closed off at night or during disturbances.
  
  When the traveller Ibn Battuta first came to Cairo in 1326, he described it as the principal district of Egypt. When he passed through the area again on his return journey in 1348, the Black Death was ravaging most major cities. He cited reports of thousands of deaths per day in Cairo. Although Cairo avoided Europe 's stagnation during the Late Middle Ages, it could not escape the Black Death, which struck the city more than fifty times between 1348 and 1517. During its initial, and most deadly waves, approximately 200,000 people were killed by the plague, and, by the 15th century, Cairo's population had been reduced to between 150,000 and 300,000. The population decline was accompanied by a period of political instability between 1348 and 1412. It was nonetheless in this period that the largest Mamluk-era religious monument, the Madrasa-Mosque of Sultan Hasan, was built. In the late 14th century, the Burji Mamluks replaced the Bahri Mamluks as rulers of the Mamluk state, but the Mamluk system continued to decline.
  
  Though the plagues returned frequently throughout the 15th century, Cairo remained a major metropolis and its population recovered in part through rural migration. More conscious efforts were conducted by rulers and city officials to redress the city's infrastructure and cleanliness. Its economy and politics also became more deeply connected with the wider Mediterranean. Some Mamluk sultans in this period, such as Barbsay (r. 1422–1438) and Qaytbay (r. 1468–1496), had relatively long and successful reigns. After al-Nasir Muhammad, Qaytbay was one of the most prolific patrons of art and architecture of the Mamluk era. He built or restored numerous monuments in Cairo, in addition to commissioning projects beyond Egypt. The crisis of Mamluk power and of Cairo's economic role deepened after Qaytbay. The city's status was diminished after Vasco da Gama discovered a sea route around the Cape of Good Hope between 1497 and 1499, thereby allowing spice traders to avoid Cairo.