لما انقرضت دولة بني الأغلب وآلت إلى بني عبيد في أخبار طوال بواسطة أبي عبد الله الصنعاني من صنعاء اليمن وكان صاحب جدل ودهاء وحذق وسياسة. كان أول ملوك هاته الدولة أبو محمد عبيد الله المهدي بن محمد الحبيب ينتهي نسبه إلى سيدنا علي رضي الله عنه وأثبت نسبهم الكريم ولي الدين بن خلدون. وقال ابن خلكان: في نسبهم خلاف كثير وهاته الدولة تعرف بدولة الشيعة، والشيعة لغة: الصحب والاتباع، وفي عرف الفقهاء والمتكلمين من الخلف والسلف تطلق على أتباع علي وبيته رضي الله عنهم وهم طوائف فمنهم الضال ومنهم العاصي، وكان عبيد الله هذا رجل الدنيا دهاء وعقلا مهيبا ولما استقل بالإمارة سنة 297 ه واستقام له الحال بعد تمهيد الأمور وتفقد العمال، غزا صقلية وإسكندرية ومصر وساعده المقدور وأسس مدينة المهدية في جزيرة جمة وحصنها وانتقل إليها سنة 308 ه وثار عليه مخلد بن كيداد الأباضي واستولى على غالب إفريقية وتوفي في ريعان الثورة سنة 323 ه وبويع لابنه أبي القاسم محمد وكان ذا نجدة وبأس وبعث مولاه كاتبه جوهرا بأسطول عظيم في جيوش كثيرة لأرض الروم وفتح مدنا وحصونا منها جنوة ومهد النواحي وقمع الثوار ومنهم مخلد المذكور وكان داعيا إلى الحق آخذا بالحسبة
When the dynasty of the Banu l-Aghlab came to an end and passed to the Banu ʿUbayd, in long reports, through Abu ʿAbd Allah al-Sanʿani, from Sanʿaʾ of Yemen — he was a man of disputation, cunning, skill and statecraft. The first of the kings of this dynasty was Abu Muhammad ʿUbayd Allah al-Mahdi ibn Muhammad al-Habib, whose lineage goes back to our master ʿAli, God be pleased with him; Wali al-Din ibn Khaldun affirmed their noble lineage. Ibn Khallikan said: there is much disagreement about their lineage. This dynasty is known as the dynasty of the Shiʿa. Shiʿa in the language means companions and followers, and in the usage of the jurists and theologians, later and earlier, it is applied to the followers of ʿAli and his house, God be pleased with them; they are sects, among them the one who has gone astray and the one who is disobedient. This ʿUbayd Allah was a man of the world in cunning and intelligence, and awe-inspiring. When he became independent in the emirate in the year 297 AH and his situation was settled after he had put affairs in order and inspected the governors, he raided Siqilliya, Alexandria and Egypt, and fate helped him. He founded the city of al-Mahdiyya on the peninsula of Jumma and fortified it, and moved to it in the year 308 AH. Makhlad ibn Kaydad the Ibadi rose against him and took most of Ifriqiya. He died in the prime of the revolt, in the year 323 AH, and allegiance was given to his son Abu l-Qasim Muhammad. He was a man of valour and might. He sent his client and secretary Jawhar with a great fleet and many armies to the land of the Byzantines, and he conquered cities and fortresses, among them Janawa, pacified the regions and suppressed the rebels, among them the said Makhlad. And he was one who called to the truth, taking up the hisba,