# Hafsid dynasty

The Hafsids (Arabic: الحفصيون al-Ḥafṣiyūn) were a Sunni Muslim dynasty of Berber descent who ruled Ifriqiya (modern day Tunisia, western Libya, and eastern Algeria) from 1229 to 1574.

## History
### Almohad Ifriqiya

The Hafsids were of Berber descent, although to further legitimize their rule, they claimed Arab ancestry from the second Rashidun caliph Omar. The ancestor of the dynasty (from whom their name is derived), was Abu Hafs Umar ibn Yahya al-Hintati, a Berber from the Hintata tribal confederation, which belonged to the greater Masmuda confederation in present-day Morocco. He was a member of the Council of Ten, one of the highest Almohad political bodies, and a close companion of Ibn Tumart, the Almohad movement's founder.
The son of Abu Hafs, Abu Muhammad Abd al-Wahid ibn Abi Hafs, was appointed by the Almohad caliph Muhammad al-Nasir as governor of Ifriqiya (generally present-day Tunisia, eastern Algeria, and western Libya) where he ruled from 1207 to 1221. He was established in Tunis, which the Almohads had chosen as the province's administrative capital.$^{:133}$ His appointment came in the wake of the defeat of Yahya Ibn Ghaniya, who had launched a serious attack against Almohad authority in the region. Abu Muhammad Abd al-Wahid was ultimately quite effective in keeping order. The caliph had granted him a significant degree of autonomy in governing, partly to help persuade him to accept this difficult position in the first place. This laid the groundwork for a future Hafsid state.$^{:101,119}$
When Abu Muhammad Abd al-Wahid died in 1221, the Almohad chiefs in Ifriqiya initially elected his son, Abu Zayd Abd al-Rahman, as the next governor. However, the Almohad caliph in Marrakesh, Yusuf II al-Mustansir, had not consented to this and was able to overrule this and appoint his own relative to the position.$^{:119}$ As Almohad authority weakened over the following years, local opposition to the Almohad governor compelled the Almohad caliph Abdallah al-Adil to appoint another Hafsid family member to the post in 1226. He chose Abu Muhammad Abdallah, a grandson of Abu Hafs. Abu Muhammad Abdallah's brother, Abu Zakariya Yahya, arrived in Tunis before him and began to reestablish order.$^{:119}$ When al-Ma'mun, the brother of Abdallah al-Adil, rebelled against the latter's authority from al-Andalus, Abu Zakariya sided with him, whereas Abu Muhammad Abdallah remained loyal to the caliph in Marrakesh. Al-Ma'mun's eventual victory resulted in Abu Zakariya being placed in charge of Ifriqiya in 1228.$^{:119}$

### Rise to power

A year later, in 1229, al-Ma'mun officially renounced Almohad doctrine. Abu Zakariya used this as a pretext to repudiate his authority and to declare himself independent. By this point, Al-Ma'mun did not have the means to stop him or to reassert control over Ifriqiya.$^{:119}$ Initially, Abu Zakariya had his name mentioned in the khutba (the sermon during Friday prayer) with the title of amir, but in 1236 or 1237 he began to adopt the caliphal title of Amir al-Mu'minin, in direct challenge to the Almohad caliph in Marrakesh.$^{:119}$
Abu Zakariya annexed Constantine (Qusantina) and Béjaïa (Bijaya) in 1230. In 1234, he chased Yahya Ibn Ghaniya out of the countryside south of Constantine in 1234, ending this lingering threat. In 1235 he captured Algiers and then established his authority as far as the Chelif River to the west. In the following years he subdued various rural tribes, such as the Hawwara, but allowed some of the Banu Tujin tribes in the central Maghreb to govern themselves as small vassal states that secured his western borders. He welcomed many refugees and immigrants from al-Andalus who were fleeing the advance of the Reconquista. He appointed some of them to important political positions and recruited Andalusi military regiments as a way of counteracting the power and influence of traditional Almohad elites.
For a time, the Nasrid ruler of Granada in al-Andalus, Ibn al-Ahmar, briefly acknowledged Abu Zakariya's suzerainty in an attempt to enlist his help against Christian forces. Ultimately, Hafsid intervention on the Iberian Peninsula was limited to sending a fleet to Muslim Valencia's aid in 1238.$^{:119–120}$ Abu Zakariya showed more interest in trying to recreate some of the former authority of the Almohads over the Maghreb and he made attempts to extend his control further west. In 1242, he captured Tlemcen from the Zayyanids, but the Zayyanid leader Yaghmurasan evaded him. The two leaders eventually came to an agreement, with Yaghmurasan continuing to rule in Tlemcen but agreeing to formally recognize Abu Zakariya's authority.$^{:120}$ That same year, Sijilmasa and Ceuta (Sabta) also recognized his authority,$^{:120}$ though these would later fall under Marinid control.$^{:107,136}$ This policy of western expansion ended with Abu Zakariya's death (1249).$^{:120}$

### Consolidation and division

His successor, Muhammad I al-Mustansir (r. 1249–1277), focused on consolidating the Hafsid state in Ifriqiya. The state benefited from expanding trade with both Europe and the Sudan region (south of the Sahara).$^{:120–121}$ In the western Maghreb (present-day Morocco), the Marinids, who had not yet fully established their rule in the region, formally recognized his authority in 1258.$^{:120}$ With the fall of Baghdad, the home of the Abbasid caliphs, that same year, the Hafsids were briefly seen as the most important rulers of the Muslim world. The Sharif of Mecca, Abu Numayy, temporarily recognized him as caliph in 1259.$^{:120}$$^{:97}$
It was during his reign that the failed Eighth Crusade took place, led by Louis IX of France. After landing at Carthage, Louis died of dysentery in the middle of his army decimated by disease in 1270.
After al-Mustansir's death in 1277, the Hafsids were riven by internal conflict, aggravated by interference from Aragon.$^{:123}$ This resulted in a split in the dynasty: one branch ruled from Tunis in the east and another branch ruled from Béjaïa (Bijaya) and Constantine (Qusantina) in the west. This division continued to characterize Hafsid politics for much of its history, with the balance of power sometimes shifting from one side to another and with intermittent successes at unifying both branches under one rule. After the initial split, the first successful reunification took place under Abu Yahya Abu Bakr II (r. 1318–1346), the ruler of the western branch who managed to take control of Tunis.

### Marinid invasions and internal crisis

Abu Yahya Abu Bakr's rule remained unstable and he resorted to making alliances with the Zayyanids and Marinids to the west. His agreement with the Marinid ruler, Abu al-Hasan (r. 1331–1348), included a marriage to his sister, who subsequently died during a failed Marinid expedition in Spain, followed by another marriage to his daughter.$^{:110}$ When Abu Yahya Abu Bakr died in 1346, his intended heir, Abu'l Abbas, was killed in Tunis by his brother, Umar, who seized power. Abu'l Abbas's chamberlain, Abu Muhammad Abdallah ibn Tafrajin, sent a letter to Abu al-Hasan urging him to intervene and invade Ifriqiya. Abu al-Hasan, having already conquered Tlemcen in 1337, seized the opportunity to further expand. He conquered Tunis in 1347 and the Hafsid governors in the region accepted his authority.$^{:110}$
The invasion, however, disturbed the balance of power in favour of the Bedouin Arab tribes, whom the Marinids were unable to sway.$^{:111,128}$ Ibn Tafrajin, who had hoped to be placed in power by the Marinids, fled to Egypt. The situation in Ifriqiya devolved into further disorder and internal rivalries, and Abu al-Hasan was forced to return west in 1349, partly to deal with a coup d'état by his son, Abu Inan. Ibn Tafrajin returned to Ifriqiya and, with Bedouin support, installed another young son of Abu Yahya Abu Bakr, Abu Ishaq, as ruler.$^{:111,128}$ Abu Inan, having successfully taken the throne from his father, invaded Ifriqiya again and captured Tunis in August 1357, but he was soon forced by his own troops to abandon the region. He returned west, retaining control only of Constantine and the cities of the central Maghreb for a time.$^{:111}$
During the mid-14th century, plague epidemics brought to Ifriqiya from Sicily caused a considerable fall in population, further weakening the Hafsid realm. To stop raids from southern tribes during plague epidemics, the Hafsids turned to the Banu Hilal to protect their rural population.$^{:37}$

### Apogee

After the Marinid threat ended, attempts to reunify the Hafsids failed until Abu al-Abbas Ahmad II (r. 1370–1394), the emir of Béjaïa and Constantine, conquered Tunis in 1370. A capable ruler and military leader, he reestablished Hafsid authority on stronger terms, centralizing power to a greater extent than ever before. Meanwhile, the Zayyanids and Marinids were occupied by internal matters.
Abu Faris Abd al-Aziz II's reign (r. 1394–1434) was considered the apogee of Hafsid power and prosperity by contemporary writers. He further consolidated his dynasty's power in Ifriqiya and extended his influence over the Zayyanids and Marinids (and the Wattasids who succeeded the latter).
The beginning of his reign was not easy since the cities of the south revolted against him. However, the new sultan quickly regained control: he reoccupied Tozeur (1404), Gafsa (1401), and Biskra (1402), subdued tribal power in the regions of Constantine and Béjaïa (1397–1402), and appointed governors of these regions to be elected officers. He also intervened against his western and eastern neighbors. He annexed Tripoli (1401) and Algiers (1410–1411). In 1424, he defeated the Zayyanid sultan, Abu Malik Abd al-Wahid, and placed another Zayyanid, Abu Abdallah Muhammad IV, on the throne of Tlemcen as his vassal. In 1428, the latter became embroiled in another war with Abu Malik Abd al-Wahid – who had now won his own support from the Hafsids – and was eventually replaced by yet another Zayyanid relative with Abu Faris Abd al-Aziz's help in 1431. Around the same time (probably in 1426), Abu Faris Abd al-Aziz also helped to install Abd al-Haqq II on the Marinid throne in Fez – under the regency of Abu Zakariya Yahya al-Wattasi – and thus obtained from him a recognition of Hafsid suzerainty.
In 1429, the Hafsids attacked the island of Malta and took 3000 slaves, although they did not conquer the island. Kaid Ridavan was the military leader during the attack. The profits were used for a great building programme and to support art and culture. However, piracy also provoked retaliation from the Christians, which several times launched attacks and crusades against Hafsid coastal cities such as the Barbary crusade (1390), the Bona crusade (1399) and the capture of Djerba in 1423.
Abu Faris Abd al-Aziz II died in 1434 during another expedition against Tlemcen. His successor, Abu 'Amr 'Uthman, had the longest reign of any Hafsid (r. 1435–1488). He largely continued the strong rule of his predecessors but he had to contend with greater challenges, including internal politics, restive Bedouin tribes in the south, and the Wattasids in the west.
Uthman conquered Tripolitania in 1458 and appointed a governor in Ouargla in 1463. He led two expeditions to Tlemcen in 1462 and 1466 and made the Zayyanids his vassals, while the Wattasid state in Morocco also formally accepted his authority. The entire Maghreb was thus briefly under Hafsid suzerainty.$^{:132}$

### Fall

In the 16th century the Hafsids became increasingly caught up in the power struggle between Spain and the Ottoman Empire-supported Corsairs. The Ottomans conquered Tunis in 1534 and held it for one year, driving out the Hafsid ruler Moulay Hassan. A year later the King of Spain and Holy Roman Emperor Charles V seized Tunis, drove the Ottomans out and restored Muley Hassan as a Habsburg tributary. Due to the Ottoman threat, the Hafsids were vassals of Spain after 1535. The Ottomans again conquered Tunis in 1569 and held it for four years. Don Juan of Austria recaptured it in 1573. The Ottomans reconquered Tunis in 1574, and Muhammad VI, the last Caliph of the Hafsids, was brought to Constantinople and was subsequently executed due to his collaboration with Spain and the desire of the Ottoman Sultan to take the title of Caliph as he now controlled Mecca and Medina.

## Economy

The Hafsids, with their location in Ifriqiya, was rich in agriculture and trade. Instead of placing the capital at inland cities such as Kairouan, Tunis was chosen as the capital due to its position on the coast as a port linking the Western and Eastern Mediterranean. Christian merchants from Europe were given their own enclaves in various cities on the Mediterranean coast, promoting trans-Mediterranean trade. Under the Hafsids, commerce and diplomatic relations with Christian Europe grew significantly, however piracy against Christian shipping grew as well, particularly during the rule of Abd al-Aziz II (1394–1434). By the mid-14th century, the population of Tunis had grown to 100,000. The Hafsids also had a large stake in trans-Saharan trade through the caravan routes from Tunis to Timbuktu and from Tripoli to sub-Saharan Africa.$^{:34–36}$

## Culture
### Intellectual activity

The Hafsids were effective patrons of culture and education. They were the first to introduce madrasas to the Maghreb.$^{:209}$ Arabic literacy and religious education thus increased, with Kairouan, Tunis and Bijaya hosting famous university-mosques. Kairouan continued to serve as a center of the Maliki school of religious doctrine.$^{:37}$As the political center of the country shifted to Tunis, the Great Mosque of al-Zaytuna, the city's main mosque, became the country's leading center of learning. Of great impact on culture were immigrants from al-Andalus, whom Abu Zakariya encouraged to come to his realm in the 13th century. Among the most important figures was the historian and intellectual, Ibn Khaldun, born in Tunis and of Andalusi descent.

### Architecture

The Hafsids were significant builders, particularly under the reigns of successful leaders like Abu Zakariya (r. 1229–1249) and Abu Faris (r. 1394–1434), though not many of their monuments have survived intact to the present-day.$^{:208}$ While Kairouan remained an important religious center, Tunis was the capital and progressively replaced it as the main city of the region and the main center of architectural patronage. Unlike the architecture further west, Hafsid architecture was built primarily in stone (rather than brick or mudbrick) and appears to have featured much less decoration.$^{:208}$ In reviewing the history of architecture in the western Islamic world, scholar Jonathan Bloom remarks that Hafsid architecture seems to have "largely charted a course independent of the developments elsewhere in the Maghrib."$^{:213}$
The Kasbah Mosque of Tunis was one of the first works of this period, built by Abu Zakariya (the first independent Hafsid ruler) at the beginning of his reign. Its floor plan had noticeable differences from previous Almohad-period mosques but the minaret, completed in 1233, bears very strong resemblance to the minaret of the earlier Almohad Kasbah Mosque in Marrakesh. Other foundations from the Hafsid period in Tunis include the Haliq Mosque (13th century) and the al-Hawa Mosque (1375). The Bardo Palace (today a national museum) was also begun by the Hafsids in the 15th century, and is mentioned in historical records for the first time during the reign of Abu Faris.$^{:208}$ The Hafsids also made significant renovations to the much older Great Mosque of Kairouan – renovating its ceiling, reinforcing its walls, and building or rebuilding two of its entrance gates in 1293 – as well as to the Great Mosque of al-Zaytuna in Tunis.$^{:209}$
The Hafsids also introduced the first madrasas to the region, beginning with the Madrasa al-Shamma῾iyya built in Tunis in 1238$^{:209}$ (or in 1249 according to some sources$^{:296}$). This was followed by many others (almost all of them in Tunis) such as the Madrasa al-Hawa founded in the 1250s, the Madrasa al-Ma'ridiya (1282), and the Madrasa al-Unqiya (1341). Many of these early madrasas, however, have been poorly preserved or have been considerably modified in the centuries since their foundation. The Madrasa al-Muntasiriya, completed in 1437, is among the best preserved madrasas of the Hafsid period.$^{:211}$

## Flags

According to French historian Robert Brunschvig, the Hafsid dynasty and its founding tribe, Hintata, were represented specifically with a white flag; he states : "Among the Hafsid standards carried in the parades stood out, apart, closer to the sultan and held by a man on horseback, a white standard, the "victorious standard" (al-alam al-mansûr). It is with good reason that some wanted to find in this white standard that of the Almohads, of the same color, reproducing in turn that which the Fatimids had adopted." Egyptian historiographer Al-Qalqashandi (d. 1418) mentioned white flags when he spoke about the Almohad flag in Tunisia, where he stated that: "It was a white flag called the victorious flag, and it was raised before their sultan when riding for Eid prayers or for the movement of the makhzen slaves (which were the ordinary people of the country and the people of the markets)." Historian Charles-André Julien also speaks of Hafsid sovereigns doing parades with their court while hoisting their own white standard, overshadowing multicolored flags of embroidered silk.
The Book of Knowledge of All Kingdoms, written by a Franciscan friar in the 14th century, describes the flag of Tunis as being white with a black moon at its center. Other cities within modern Tunisia and eastern Algeria were also reported having white flags with a moon.
* Flags of Hafsids on portolans and from other sources
* Early red flag with white or yellow crescent of the 14th century, reported by Marino Sanudo (ca. 1321), Pietro Vesconte (1325), Angelino Dulcerta (1339) and the Catalan Atlas (1385)
* White with blue crescent according to Jacobo Russo, 1550 (last period of the kingdom)

## Hafsid rulers

Part of a series on the :
History of Tunisia :
PrehistoricPrehistory :
Ancient Carthage12th C.–146 BC 1st Roman (Province)146 BC–435 Vandal435–534 2nd Roman (Byzantine) / Byzantine North Africa534–698 Prefecture534–590 Exarchate590–698 :
Early Islamic Umayyad698–750 Abbasid750–800 Aghlabid800–909 Fatimid909–973 :
Medieval Zirid973–1148 Norman1148–1160 Almohad1160–1229 Hafsid1229–1574 :
Early modern Ottoman 1574–1705 Husainid 1705–1881 :
Modern French rule 1881–1956 Kingdom of Tunisia 1956–1957 Bourguiba rule 1957–1987 Ben Ali coup 1987 Ben Ali rule 1987–2011 Tunisian revolution 2010–2011 Political crisis 2013–2014 COVID-19 pandemic 2020 Saied self-coup 2021 :
Africa portal • History portal :
vte :
Part of a series on the :
History of Libya :
Libya portal :
vte :
| S. n. | Name | Birth date | Death date | Reign | Notes |
| – | Abu Muhammad Abd al-Wahid ibn Abi Hafs | unknown | 1222 | 1207–1222 | Not yet a sultan, just a local minor leader. |
| – | Abu Muhammad Abd Allah ibn Abd al-Wahid | unknown | 1229 | 1222–1229 | Not yet a sultan, just a local minor leader. |
| 1st | Abu Zakariya Yahya | 1203 | 5 October 1249 | 1229–1249 | |
| 2nd | Muhammad I al-Mustansir | 1228 | 1277 | 1249–1277 | |
| 3rd | Yahya II al-Wathiq | unknown | 1279 | 1277–1279 | |
| 4th | Ibrahim I | unknown | 1283 | 1279–1283 | |
| 5th | Abd al-Aziz I | unknown | 1283 | 1283 | |
| 6th | Ibn Abi Umara | unknown | 1284 | 1283–1284 | |
| 7th | Abu Hafs Umar bin Yahya | unknown | 1295 | 1284–1295 | |
| 8th | Abu Asida Muhammad II | 1279 | September 1309 | 1295–1309 | |
| 9th | Abu Yahya Abu Bakr ash-Shahid | unknown | September 1309 | 1309 | |
| 10th | Abu-l-Baqa Khalid An-Nasr | unknown | 1311 | 1309–1311 | |
| 11th | Abd al-Wahid Zakariya ibn al-Lihyani | 1253 | 1326 | 1311–1317 | |
| 12th | Abu Darba Muhammad Al-Mustansir | unknown | 1323 | 1317–1318 | |
| 13th | Abu Yahya Abu Bakr II | unknown | 19 October 1346 | 1318–1346 | |
| 14th | Abu-l Abbas Ahmad | unknown | 1346 | 1346 | |
| 15th | Abu Hafs Umar II | unknown | 1347 | 1346–1347 | |
| 16th | Abu al-Abbas Ahmad al-Fadl al-Mutawakkil | unknown | 1350 | 1347–1350 | |
| 17th | Abu Ishaq Ibrahim II | October or November 1336 | 19 February 1369 | 1350–1369 | |
| 18th | Abu-l-Baqa Khalid II | unknown | November 1370 | 1369–1370 | |
| 19th | Ahmad II | 1329 | 3 June 1394 | 1370–1394 | |
| 20th | Abd al-Aziz II | 1361 | July 1434 | 1394–1434 | |
| 21st | Abu Abd-Allah Muhammad al-Muntasir | unknown | 16 September 1435 | 1434–1435 | |
| 22nd | Abu 'Amr 'Uthman | February 1419 | September 1488 | 1435–1488 | |
| 23rd | Abu Zakariya Yahya II | unknown | 1489 | 1488–1489 | |
| 24th | Abd al-Mu'min | unknown | 1490 | 1489–1490 | |
| 25th | Abu Yahya Zakariya III | unknown | 1494 | 1490–1494 | |
| 26th | Abu Abdallah Muhammad IV al-Mutawakkil | unknown | 1526 | 1494–1526 | |
| 27th | Muhammad V (“Moulay Hasan”) | unknown | 1543 | 1526–1543 | |
| 28th | Ahmad III | c. 1500 | August 1575 | 1543–1569 | |
| Ottoman conquest (1569–1573) ||||||
| 29th | Muhammad VI | unknown | 1594 | 1573–1574 | |