The first mosque in Marrakesh was erected at this place by the Almoravid emir Yusuf ibn Tashfin in the 1070s. However, it was almost completely rebuilt in early 19th century by the Alaouite sultan Suleiman, with hardly any trace left of its original Amoravid or Almohad design. Non-Muslims are not allowed to enter it.