was at its broadest and its prestige had reached new heights after centuries of expansion and elite patronage. Among the subjects taught around this period or shortly after were traditional religious subjects such as the Quran and fiqh (Islamic jurisprudence), and other sciences like grammar, rhetoric, logic, medicine, mathematics, astronomy and geography. By contrast, some subjects like alchemy/chemistry were never officially taught as they were considered too unorthodox.Starting in the late 13th century, and especially in the 14th century, the Marinid dynasty was responsible for constructing a number of formal madrasas in the areas around al-Qarawiyyin's main building. The first of these was the Saffarin Madrasa in 1271, followed by al-Attarine in 1323, and the Mesbahiya Madrasa in 1346. A larger but much later madrasa, the Cherratine Madrasa, was also built nearby in 1670. These madrasas taught their own courses and sometimes became well-known institutions, but they usually had narrower curricula or specializations. One of their most important functions seems to have been to provide housing for students from other towns and cities – many of them poor – who needed a place to stay while studying at al-Qarawiyyin. Thus, these buildings acted as complimentary or auxiliary institutions to al-Qarawiyyin itself, which remained the center of intellectual life in the city. Al-Qarawiyyin also compiled a large selection of manuscripts that were kept at a library founded by the Marinid sultan Abu Inan Faris in 1349. The collection housed numerous works from the Maghreb, al-Andalus, and the Middle East. Part of the collection was gathered decades earlier by Sultan Abu Yusuf Ya'qub (ruled 1258–1286), who persuaded Sancho IV of Castile to hand over a number of works from the libraries of Seville, Córdoba, Almeria, Granada, and Malaga in al-Andalus/Spain. Abu Yusuf initially housed these in the nearby Saffarin Madrasa (which he had recently built), but later moved them to al-Qarawiyyin. Among the most precious manuscripts currently housed in the library are volumes from the Al-Muwatta of Malik written on gazelle parchment, a copy of the Sirat by Ibn Ishaq, a 9th-century Quran manuscript (also written on gazelle parchment), a copy of the Quran given by Sultan Ahmad al-Mansur in 1602, a copy of Ibn Rushd's Al-Bayan Wa-al-Tahsil wa-al-Tawjih (a commentary on Maliki fiqh) dating from 1320, and the original copy of Ibn Khaldun's book Al-'Ibar (including the Muqaddimah) gifted by the author in 1396. Recently rediscovered in the library is an