The early history of the necropolis is not well known. The necropolis is located right behind the qibla wall (in this case the southeastern wall) of the Kasbah Mosque which was built, along with the surrounding royal kasbah (citadel), by the Almohad caliph Abu Yusuf Ya'qub (al-Mansur) in the late 12th century (1185-1190). Accordingly, it is believed that this was the site of a necropolis even in Almohad times, though there's no evidence of any significant figures being buried here at that time (the Almohad rulers were buried at Tinmal instead).: It is known, however, that in the 14th century, during the Marinid dynasty period, Sultan Abu al-Hasan was buried here temporarily in 1351. He died while in exile in the High Atlas mountains and Marrakesh was thus the closest city for burial (which, under Islamic tradition, must be carried out quickly). A few months later his body was then moved and reburied in the Marinid royal necropolis at Chellah (near Rabat). A marble tombstone with a long inscription attests to his first burial in the Marrakesh kasbah necropolis, and this tombstone is still found in the Chamber of the Three Niches in the Saadian tombs today (presumably moved there during or after Saadian construction).: The Marinid sultan's burial here suggests that it must have already been a cemetery at the time. Afterwards, the necropolis also became the burial site of the Hintati emirs who controlled the region of Marrakesh from the mid-15th century until the 1520s. Some of their epitaphs are still visible today.