The mosque was first built in the late 12th century under the Almohad dynasty, and is located in the Ain al-Kheil ("Spring of the Horse") neighbourhood. It is notable for its association with Ibn Arabi, the Sufi master from al-Andalus, who visited Fes multiple times and frequently retreated to this mosque for prayer and meditation in the late 1190s.[1][2][3]