The Juyushi Mosque (Arabic: الجامع الجيوشى, lit. 'Mosque of the Armies') was built by the vizier Badr al-Jamali who was Amir al-Juyush (Arabic: امير الجيوش, lit. 'Commander of the Armies') for the Fatimid Caliphate. The mosque was completed in 478 AH/1085 CE under the patronage of Imam-Caliph al-Mustansir Billah. It was built on an end of the Mokattam to ensure a view of Cairo. In the Ottoman period, the mosque was probably used by Sufis as a monastery.