 According to legend, 'Abdullah and his son were fulfilling a prophecy that the Mahdi would come from Mesopotamia to Sijilmasa.They hid among the population of Sijilmasa, then an independent emirate, ruled by Prince Yasa' ibn Midrar (r. 884–909).Abdullāh al-Mahdi's control soon extended over all of the Maghreb, an area consisting of the modern countries of Morocco, Algeria, Tunisia, and Libya, which he ruled from Mahdia.