Abu Zakariya 1285-1301 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. He did not claim to be caliph, unlike his cousins in Tunis. Although he retained the style of emir, he took a title reminiscent of a caliphal name, Al-Muntahab li-Ihyā Din-Allah. He tried to reunite Hafsid lands by advancing on Tunis to oust his uncle
Abu Hafs Umar bin Yahya, but the
Zayyanid ruler of
Tlemcen, Uthman, allied with Tunis, threatened Béjaïa and forced his withdrawal. 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. Under the agreement which followed, the first to die was to be succeeded by the other. However when Abu Asida died in 1309 the sheikhs of Tunis proclaimed a son of Abu Faris bin Ibrahim I, named Abu Yahya Abu Bakr I al-Shahid instead. It took Abu-l Baqa seventeen days to eliminate his rival and take over Tunis. However the reunification of Hafsid domains was transient. No sooner was Abu-l Baqa installed in Tunis than rebellion broke out in Constantine, led by his own brother,
Abu Yahya Abu Bakr. The notables of Tunis found Abu-l-Baqa's rule too harsh and many supported the cause of his brother. As his support ebbed away, Abu-l-Baqa surrendered to his brother in the hope of saving his life, but he was quickly assassinated. Although Abu Yahya Abu Bakr continued to rule in Béjaïa, he quickly lost control of Tunis to his remote cousin,
Abd al-Wahid Zakariya ibn al-Lihyani, so the Hafsid state remained divided.
Abu Yahya Abu Bakr 1311-1318 Abu Yahya Abu Bakr maintained generally good relations with Tunis at first, but warred against Tlemcen. 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. ==Second period of independence==