Built outside Cairo's original walls (those standing now were constructed in 1087), this mosque saw varied usage during its lifetime. During the Crusades it held European prisoners of war who built a chapel inside it. Salah al-Din (1137–1193) tore the chapel down when he used the structure as a stable. In the 19th century, Napoléon's troops used it as a storehouse and fortress; Muhammad Ali closed part of it off for use as a zawya (small Sufi school); and, until the establishment of the Museum of Islamic Arts in 1896, it served as a repository for Islamic treasures.
Originally built in 1010 by the Fatimid caliph al-Hakim bi-Amr Allah, this gigantic mosque was restored under the aegis of the Aga Khan, spiritual leader of the Isma'ili Shi’a sect. Al-Hakim was an eccentric character. Some of the strangest edicts were declared during his caliphate, including one ban on mulokhia, a favorite Egyptian dish (he didn't care for it) and another on women's shoes (to prevent them from going out in public). He liked riding around town on his donkey to ensure that his orders were being obeyed, but one night, he rode off into the Mokattam hills, never to be seen again. The Druze claim that he has vanished only temporarily and will return to lead them to victory.
Architecturally, the mosque’s most significant elements are its minarets, which were restored and reinforced by Baybars II in 1303, giving them that impressive trapezoidal base. Nevertheless, its scale and history are important, and its courtyard is large and breezy, making it a comfortable place to rest or meditate.