AbdullÄ h al-Mahdi 's control soon extended over all of central Maghreb , an area consisting of the modern countries of Morocco , Algeria , Tunisia and Libya , which he ruled from Mahdia , his newly-built capital in Tunisia . AbdullÄ h al-Mahdi 's control soon extended over all of central Maghreb , an area consisting of the modern countries of Morocco , Algeria , Tunisia , and Libya , which he ruled from Mahdia , his newly built capital in Tunisia .