Al Mahdi Captured and FreedSijilmasa, Morocco
Due to persecution from the Abbasids, al-Mahdi Billah is forced to flee to Sijilmasa (today's Morocco) where he starts spreading his Ismaili beliefs.
However, he was captured by the Aghlabid ruler Yasah ibn Midrar due to his Ismaili beliefs and thrown into a dungeon in Sijilmasa. In early 909 Al-Shi'i sent a large expedition force to rescue Al Mahdi, conquering the Ibadi state of Tahert on its way there. After gaining his freedom, Al Mahdi became the leader of the growing state and assumed the position of imam and caliph. Al Mahdi then led the Kutama Berbers who captured the cities of Qairawan and Raqqada. By March 909, the Aghlabid Dynasty had been overthrown and replaced with the Fatimids. As a result, the last stronghold of Sunni Islam in North Africa was removed from the region.