# Hafsids of Béjaïa

The Hafsids of Béjaïa were a dynasty of independent or autonomous emirs. They were a branch of the Hafsid dynasty that ruled from Tunis; at times they recognised the caliph in Tunis and at other times they ruled independently. Periodically there was also conflict between the two branches of the dynasty.$^{:35–101}$

## Before the Hafsids

The Hammadid dynasty made Béjaïa its capital city in 1090. Under the Almohad Caliphate Béjaïa was the capital of the western territories, corresponding with the former Hammadid domains, with Tunis the capital of the east. The Almohad caliph Abd al-Mu'min made his son governor of Béjaïa.$^{:5}$ In 1184 it was briefly taken by an invasion force from Majorca in support of a member of the ousted Almoravid dynasty, Ali bin Ishaq bin Gania. Thereafter, following the restoration of Almohad rule, governors of Bejaïa were mostly appointed from the immediate family of the caliph.$^{:8,12}$

## Early Hafsid period

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.$^{: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.$^{:24}$ He was heir apparent but predeceased his father in 1249.$^{:38}$ The new caliph Muhammad I al-Mustansir appointed his brother Abu Hafs governor.$^{:68}$
Under the next caliph Yahya II al-Wathiq Béjaïa was the centre of a revolt. The Chancellor was a deeply unpopular man named Ibn al-Habbabar. 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î. When the governor had the chancellor assassinated in 1278 he was then obliged to look for someone who could replace the existing authority in Tunis. Al-Hintâtî therefore called on the caliph’s uncle, Abu Ishaq Ibrahim, to rebel. 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. Ibrahim also had the backing of king Pedro III of Aragon. 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. His seizure of power was peaceful after the army leaders rose up and agreed to recognize him.
Ibrahim’s short reign marked the beginning of the division of the Hafsid domains and the separation of the Emirate of Béjaïa from the main Hafsid caliphate. Ibrahim was overthrown by a rebellion by Ibn Abi Umara in the south of his territories. In January 1283, as panic seized Tunis, Ibrahim took flight. 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.$^{:85}$
Abu Faris led an army against Ibn Abi Umara which met his forces in June 1283 near Kalaat es Senam. The result was the total defeat of Hafsid forces. Abu Faris was killed in battle, while three of his brothers and his nephew were captured and executed. The only family member who managed to escape was Ibrahim’s half-brother Abu Hafs Umar bin Yahya. Ibrahim and his remaining son Abu Zakariya fled Béjaïa. 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.$^{:86}$ Abu Hafs Umar was eventually able to regain power in Tunis, but by this time Ibrahim’s son Abu Zakariya had established himself as ruler in Béjaïa.$^{:102}$

## First period of independence
### 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.$^{:103}$ Abu Zakariya was however able to consolidate his rule over Biskra, Ouargla and the Aurès Mountains.$^{: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.$^{:112}$

### Abu-l Baqa Khalid An-Nasr 1301-1311

In 1301 Abu Zakariya was succeeded by his son Abu-l-Baqa Khalid An-Nasr. In 1307 Béjaïa was visited by the Christian scholar Ramon Llull, who claimed to prove the falsehood of Islam. He was beaten and the qadi had him locked up. He remained imprisoned for six months, until Abu-l-Baqa decided to release him and expel him from his domains.
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.$^{:127}$

### 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.$^{:128,130–133}$

## Second period of independence

The period of unity was followed by wars of succession after Abu Yahya Abu Bakr’s death, and in 1347 by the invasion of the Marinid rulers Abu al-Hasan Ali ibn Othman and Abu Inan Faris. Eventually Abu Ishaq Ibrahim II secured control of Tunis and ceded Béjaïa to his cousin Abu Abdullah ibn Abu Zakaria, son of Abu Zakaria Yahya, son of Abu Yahya Abu Bakr.$^{:166–180}$ It was under the government of abu Abddullah that Ibn Khaldun served as prime minister.
Abu Abdullah soon found himself in conflict with another Hafsid cousin, Abu'l Abbas of Constantine. In May 1366 Abu'l Abbas took Béjaïa from him, thereby uniting western Ifriqiya under a single ruler once again. On the death of Abu Ishaq Ibrahim in Tunis, Abu'l Abbas was quickly able to reunite the western and eastern domains, for the third time, in 1370.$^{:183–5}$

## Third period of independence

The third period of independence of the Hafsids of Béjaïa began when Abu 'Amr 'Uthman was caliph in Tunis (1435-1488). 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. In the spring of 1436, Abu-l-Hasan won the support of the Awlad Abi-l-Layl in his bid for the Hafsid throne. The rebels laid siege to Constantine for a month and even reached the walls of the capital of Tunis itself. The initial rebellion was routed by Uthman and his supporters in a battle near the Roman ruins of Tipasa on October 4, 1436. Abu-l-Hasan fled back to Béjaïa. His rebellion continued with the support of Kabyle chieftains until 1439. On November 9 of that year, Uthman's troops captured Béjaïa but Abu-l-Hasan escaped and continued an insurgency for more than a dozen years, recapturing Béjaïa for about three weeks in 1446 and besieging it again in 1452. In that very year, however, he was betrayed by his allies in Kabylia and brought to Constantine as a captive. He was quickly executed and his head presented to Uthman.$^{:243–4}$
The final period of independence is recorded by chroniclers towards the end of the 15th century. Leo Africanus reported that on the eve of the Spanish conquest, the region of Béjaïa was independent from Tunis. Al-Marīnī also confirmed that in the early 16th century, the emir of Béjaïa was independent of Tunis as were the emirs of Constantine and Annaba. In his time, the emir of Béjaïa was a certain Abūl-’Abbās ‘Abd al-’Azīz. Between this Abūl-Abbās and his brother Abū Bakr, Emir of Constantine, there was a struggle for control of the region. This state of hostility between the different emirs explains the lack of a unified response to the Spanish Capture of Bejaia (1510).