Hafsids of Béjaïa

[3]: 8, 12 The founder of the Hafsid dynasty, Abu Zakariya Yahya, declared independence from the Almohads in 1229 in Tunis and took both Constantine and Béjaïa in 1230.

[4][3]: 22  Following the Almohad practice of appointing close family members to rule Béjaïa, he made his son Abu Yahya Zakariyya governor soon after.

Ibn Khaldoun relates that the Chancellor sent his brother Abû al-Alâ 'Idrîs to Béjaïa to take care of the finances of the city, alongside the governor, the Almohad Muḥammad ben Abi Hilâl al-Hintâtî.

The latter had already revolted against Abû `Abd Allah Muhammad al-Mustansir, his brother and father of Abu Zakariyâ Yahyâ II, and had fled first to Andalusia then to Tlemcen.

[6] Welcomed by Muḥammad ben Abi Hilâl al-Hintâtî and the notables of Béjaïa, he took the city in April 1279 and in August of the same year entered Tunis where he was recognized as ruler.

He reached Béjaïa in February, where the governor, his son Abu Faris, obliged him to abdicate, declaring himself Caliph with the name Al-Mu’tamid.

[3]: 85 Abu Faris led an army against Ibn Abi Umara which met his forces in June 1283 near Kalaat es Senam.

The only family member who managed to escape was Ibrahim’s half-brother Abu Hafs Umar bin Yahya.

The son reached safety in Tlemcen but Ibrahim was captured and sent back to Béjaïa where he was executed by an emissary of Ibn Abi Umara in June 1283.

[3]: 102 Amid the chaos resulting from the rebellion of Ibn Abi Umara, Abu Zakariya was recognised as ruler not only in Béjaïa but in Constantine, Algiers and Dellys.

[3]: 100  Later in his reign he faced a new threat from the west in the shape of the Marinid ruler Abu Yaqub Yusuf an-Nasr who first seized Algiers and then attacked Béjaïa itself.

[7] Abu-l-Baqa Khalid made diplomatic approaches to Abu Asida Muhammad II, the Hafsid ruler of Tunis, to end the division between the two branches of the family.

In 1315 or 1316 he began attacking Tunis; in 1317 al-Lihyaní fled and abdicated in favor of his son, but in early 1318 Abu-Yahya Abu-Bakr made his entrance into the capital, thereby once again reuniting the Hafsid domains.

The previous caliph al-Muntasir had appointed a son of Abu Faris Abd al-Aziz II named Abu-l-Hasan Ali as the governor of Béjaïa.

This state of hostility between the different emirs explains the lack of a unified response to the Spanish Capture of Bejaia (1510).