# History of medieval Tunisia

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 Tunisia 1881–1956 Kingdom of Tunisia 1956–1957 Bourguiba rule 1957–1987 Ben Ali coup 1987 Ben Ali rule 1987–2011 Tunisian revolution 2011 Parliamentary system 2011–present :
Africa portal • History portal :
vte :
The medieval era of Tunisia began with what would eventually return Ifriqiya (Tunisia and the entire Maghrib) to local Berber rule. The Shia Islamic Fatimid Caliphate departed to their newly conquered territories in Egypt leaving the Zirid dynasty to govern in their stead. The Zirids would eventually break all ties to the Fatimids and formally embrace Sunni Islamic doctrines.
During this time there arose in Maghrib two strong local successive movements dedicated to Muslim purity in its practice. The Almoravids emerged in the far western area in al-Maghrib al-Aksa (Morocco) establishing an empire stretching as far north as modern Spain (al-Andalus) and south to Mauretania; Almoravid rule never included Ifriqiya. Later, the Berber religious leader Ibn Tumart founded the Almohad movement, supplanted the Almoravids, and would eventually bring under the movement's control al-Maghrib and al-Andalus. Almohad rule would be succeeded by the Tunis-based Hafsids. The Hafsids were a local Berber dynasty and would retain control with varying success until the arrival of the Ottomans in the western Mediterranean.

## Berber sovereignty

Following the Fatimids, for the next half millennium Berber Ifriqiya enjoyed self-rule (1048−1574). The Fatimids were Shi'a, specifically of the more controversial Isma'ili branch. They originated in Islamic lands far to the east. Today, and for many centuries, the majority of Tunisians identify as Sunni (also from the east, but who oppose the Shi'a). In Ifriqiyah, at the time of the Fatimids, there was disdain for any rule from the east regardless if it was Sunni or Shi'a. Hence the rise in medieval Tunisia (Ifriqiya) of regimes not beholden to the east (al-Mashriq), which marks a new and a popular era of Berber sovereignty.
Initially the local agents of the Fatimids managed to inspire the allegiance of Berber elements around Ifriqiya by appealing to Berber distrust of the Islamic east, here in the form of Aghlabid rule. Thus, the Fatimids were ultimately successful in acquiring local state power. Nonetheless, once installed in Ifriqiya, Fatimid rule greatly disrupted social harmony; they imposed high, unorthodox taxes, leading to a Kharijite revolt. Later, the Fatimids of Ifriqiya managed to accomplish their long-held, grand design for the conquest of Islamic Egypt; soon thereafter their leadership relocated to Cairo. The Fatimids left the Berber Zirids as their local vassals to govern in the Maghrib. Originally only a client of the Fatimid Shi'a Caliphate in Egypt, the Zirids eventually expelled the Shi'a Fatimids from Ifriqiya. In revenge, the Fatimids sent the disruptive Banu Hilal against Ifriqiya, which led to a period of social chaos and economic decline.
The independent Zirid dynasty has been viewed historically as a Berber kingdom; the Zirids were essentially founded by a leader among the Sanhaja Berbers. Concurrently, the Sunni Umayyad Caliphate of Córdoba were opposing and battling against the Shi'a Fatimids. Perhaps because Tunisians have long been Sunnis themselves, they may currently evidence faint pride in the Fatimid Caliphate's rôle in Islamic history. In addition to their above grievances against the Fatimids (per the Banu Hilal), during the Fatimid era the prestige of cultural leadership within al-Maghrib shifted decisively away from Ifriqiya and instead came to be the prize of al-Andalus.
During the interval of generally disagreeable Shi'a rule, the Berber people appear to have ideologically moved away from a popular antagonism against the Islamic east (al-Mashriq), and toward an acquiescence to its Sunni orthodoxy, though of course mediated by their own Maliki school of law (viewed as one of the four orthodox madhhab by the Sunni). Professor Abdallah Laroui remarks that while enjoying sovereignty the Berber Maghrib experimented with several doctrinal viewpoints during the 9th to the 13th centuries, including the Khariji, Zaydi, Shi'a, and Almohad. Eventually they settled on an orthodoxy, on Maliki Sunni doctrines. This progression indicates a grand period of Berber self-definition.
Tunis under the Almohads would become the permanent capital of Ifriqiya. The social discord between Berber and Arab would move toward resolution. In fact it might be said that the history of the Ifriqiya prior to this period was prologue, which merely set the stage; henceforth, the memorable events acted on that stage would come to compose the History of Tunisia for its modern people. Prof. Perkins mentions the preceding history of rule from the east (al-Mashriq), and comments that following the Fatimids departure there arose in Tunisia an intent to establish a "Muslim state geared to the interests of its Berber majority." Thus commenced the medieval era of their sovereignty.

## Berber language history
### Result of migrations

Twenty or so Berber languages (also called Tamazight) are spoken in North Africa. Berber speakers were once predominant over all this large area, but as a result of Arabization and later local migrations, today Berber languages are reduced to several large regions (in Morocco, Algeria, and the central Sahara) or remain as smaller language islands. Several linguists characterize the Berber spoken as one language with many dialect variations, spread out in discrete regions, without ongoing standardization. The Berber languages may be classified as follows (with some more widely known languages or language groups shown in italics). Ethnic historical correspondence is suggested by the designation |Tribe|.
* I. Guanche [extinct] - (Canary Islands).
* II. Old Libyan [extinct] - (West of ancient Egypt).
* III. Berber Proper.
** A. Eastern: Siwa, Awjila, Sokna - (Libya & Egypt).
** B. Tuareg - (Central Sahara region). |Sanhaja|
** C. Western: Zenaga - (Mauritania & Senegal). |Sanhaja|
** D. Northern Berber languages - (Maghrib).
*** 1. Atlas: Shilha, Central Morocco Tamazight - (Morocco & Algeria). |Masmuda|
*** 2. Kabyle - (East of Algiers). |Sanhaja|
*** 3. Zenati - (Morocco, Algeria, & Tunisia). |Zenata|
Nota Bene: The classification and nomenclature of Berber languages lack complete consensus.

### Script, writings

The Libyan Berbers developed their own writing system, evidently derived from Phoenician, as early as the 4th century BC. It was a boustrophic script, i.e., written left to right then right to left on alternating lines, or up and down in columns. Most of these early inscriptions were funerary and short in length. Several longer texts exist, taken from Thugga, modern Dougga, Tunisia. Both are bilingual, being written in Punic with its letters and in Berber with its letters. One throws some light on the governing institutions of the Berbers in the 2nd century BC. The other text begins: "This temple the citizens of Thugga built for King Masinissa.... " Today the script descendent from the ancient Libyan remains in use; it is called Tifinagh.
Berber, however, no longer is widely spoken in present-day Tunisia; e.g., centuries ago many of its Zenata Berbers became Arabized. Today in Tunisia the small minority that speaks Berber may be heard on Jerba island, around the salt lakes region, and near the desert, as well as along the mountainous border with Algeria (across this frontier to the west lies a large region where the Zenati Berber languages and dialects predominate). In contrast, use of Berber is relatively common in Morocco, and also in Algeria, and in the remote central Sahara. Berber poetry endures, as well as a traditional Berber literature.

## Berber tribal affiliations

The grand tribal identities of Berber antiquity were said to be the Mauri, the Numidians, and the Gaetulians. The Mauri inhabited the far west (ancient Mauritania, now Morocco and central Algeria). The Numidians were located between the Mauri and the city-state of Carthage. Both had large sedentary populations. The Gaetulians were less settled, with large pastoral elements, and lived in the near south on the margins of the Sahara. The medieval historian of the Maghrib, Ibn Khaldun, is credited or blamed for theorizing a causative dynamic to the different tribal confederacies over time. Issues concerning tribal social-economies and their influence have generated a large literature, which critics say is overblown. Abdallah Laroui discounts the impact of tribes, declaring the subject a form of obfuscation which cloaks suspect colonial ideologies. While Berber tribal society has made an impact on culture and government, their continuance was chiefly due to strong foreign interference which usurped the primary domain of the government institutions, and derailed their natural political development. Rather than there being a predisposition for tribal structures, the Berber's survival strategy in the face of foreign occupation was to figuratively retreat into their own way of life through their enduring tribal networks. On the other hand, as it is accepted and understood, tribal societies in the Middle East have continued over millennia and from time to time flourish.
Berber tribal identities survived undiminished during the long period of dominance by the city-state of Carthage. Under centuries of Roman rule also tribal ways were maintained. The sustaining social customs would include: communal self-defense and group liability, marriage alliances, collective religious practices, reciprocal gift-giving, family working relationships and wealth. Abdallah Laroui summarizes the abiding results under foreign rule (here, by Carthage and by Rome) as: Social (assimilated, nonassimilated, free); Geographical (city, country, desert); Economic (commerce, agriculture, nomadism); and, Linguistic (e.g., Latin, Punico-Berber, Berber).
During the initial centuries of the Islamic era, it was said that the Berbers tribes were divided into two blocs, the Butr (Zanata and allies) and the Baranis (Sanhaja, Masmuda, and others). The etymology is unclear, perhaps deriving from tribal customs for clothing ("abtar" and "burnous"), or perhaps words coined to distinguish the nomad (Butr) from the farmer (Baranis). The Arabs drew most of their early recruits from the Butr. Later, legends arose which spoke of an obscure, ancient invasion of North Africa by the Himyarite Arabs of Yemen, from which a prehistoric ancestry was evidently fabricated: Berber descent from two brothers, Burnus and Abtar, who were sons of Barr, the grandson of Canaan (Canaan being the grandson of Noah through his son Ham). Both Ibn Khaldun (1332–1406) and Ibn Hazm (994–1064) as well as Berber genealogists held that the Himyarite Arab ancestry was totally unacceptable. This legendary ancestry, however, played a rôle in the long Arabization process that continued for centuries among the Berber peoples.
In their medieval Islamic history the Berbers may be divided into three major tribal groups: the Zanata, the Sanhaja, and the Masmuda. These tribal divisions are mentioned by Ibn Khaldun (1332–1406). The Zanata early on allied more closely with the Arabs and consequently became more Arabized, although Znatiya Berber is still spoken in small islands across Algeria and in northern Morocco (the Rif and north Middle Atlas). The Sanhaja are also widely dispersed throughout the Maghrib, among which are: the sedentary Kabyle on the coast west of modern Algiers, the nomadic Zanaga of southern Morocco (the south Anti-Atlas) and the western Sahara to Senegal, and the Tuareg (al-Tawarik), the well-known camel breeding nomads of the central Sahara. The descendants of the Masmuda are sedentary Berbers of Morocco, in the High Atlas, and from Rabat inland to Azru and Khanifra, the most populous of the modern Berber regions.
Medieval events in Ifriqiya and al-Maghrib often have tribal associations. Linked to the Kabyle Sanhaja were the Kutama tribes, whose support worked to establish the Fatimid Caliphate (909–1171, only until 1049 in Ifriqiya); their vassals and later successors in Ifriqiya the Zirids (973–1160) were also Sanhaja. The Almoravids (1056–1147) first began far south of Morocco, among the Lamtuna Sanhaja. From the Masmuda came Ibn Tumart and the Almohad movement (1130–1269), later supported by the Sanhaja. Accordingly, it was from among the Masmuda that the Hafsid dynasty (1227–1574) of Tunis originated.

## Zirid Berber succession
### Under the Fatimids

The Zirid dynasty (972–1148) began their rule as agents of the Shi'a Fatimids (909−1171), who had conquered Egypt in 969. After removing their capital to Cairo from Mahdiya in Ifriqiya, the Fatimids also withdrew from direct governance of al-Maghrib, which they delegated to a local vassal. Their Maghriban power, however, was not transferred to a loyal Kotama Berber, which tribe had provided crucial support to the Fatimids during their rise. Instead authority was given to a chief from among the Sanhaja Berber confederacy of the central Magrib, Buluggin ibn Ziri (died 984). His father Ziri had been a loyal follower and soldier of the Fatimids.
For a time the region enjoyed great prosperity and the early Zirid court famously enjoyed luxury and the arts. Yet political affairs were turbulent. Bologguin's war against the Zenata Berbers to the west was fruitless. His son al-Mansur (r. 984–996) challenged rule by the Fatimid Shi'a Caliphate in Cairo, but without his intended effect; instead, the Kotama Berbers were inspired by the Fatimids to rebel; al-Manur did manage to subdue the Kotama. The Fatimids continued to demand tribute payments from the Zirids. After Buluggin's death, the Fatamid vassalage had eventually been split among two dynasties: for Ifriqiya the Zirid (972−1148); and for western lands [in present-day Algeria] the Hammadid (1015–1152), named for Hammad, another descendant of Buluggin. The security of civic life declined, due largely to intermittent political quarrels between the Zirids and the Hammadids, including a civil war ending in 1016. Armed attacks also came from the Sunni Umayyads of al-Andalus and from the other Berbers, e.g., the Zanatas of Morocco.
Even though in this period the Maghrib often fell into conflict, becoming submerged in political confusion, the Fatimid province of Ifriqiya at first managed to continue in relative prosperity under the Zirid Berbers. Agriculture thrived (grains and olives), as did the artisans of the city (weavers, metalworkers, potters), and the Saharan trade,. The holy city of Kairouan served also as the chief political and cultural center of the Zirid state. Soon however the Saharan trade began to decline, caused by changing demand, and by the encroachments of rival traders: from Fatimid Egypt to the east, and from the rising power of the al-Murabit Berber movement in Morocco to the west. This decline in the Saharan trade caused a rapid deterioration in the commercial well-being of Kairouan. To compensate, the Zirids encouraged the sea trade of their coastal cities, which did begin to quicken; however, they faced rigorous competition from Mediterranean traders of the rising city-states of Genoa and Pisa.

### Independence

In 1048, for both economic and popular reasons, the Zirids dramatically broke with the Shi'a Fatimid Caliphate, who had ruled them from Cairo. Instead the Zirids chose to become Sunni (always favored by most Maghribi Muslims) and hence declared their allegiance to the moribund Abbasid Caliphate in Baghdad. Consequently, many shia were killed during disturbances throughout Ifriqiya. The Zirid state seized Fatimid wealth and coinage. Sunni Maliki jurists were reestablished as the prevailing school of law.
In retaliation, the Fatimid political leaders sent against the Zirids an invasion of nomadic Arabians, the Banu Hilal, who had already migrated into upper Egypt. These warrior bedouins were induced by the Fatimids to continue westward into Ifriqiya. Ominously, westward toward Zirid Ifriqiya came the entire Banu Hilal, along with them the Banu Sulaym, both Arab tribes quitting upper Egypt where they had been pasturing their animals.
The arriving Bedouins of the Banu Hilal defeated in battle the Zirid and Hammadid Berber armies in 1057, and sack the Zirid capital Kairouan. It has since been said that much of the Maghrib's misfortunes to follow can be traced to the chaos and regression occasioned by their arrival, although historical opinion is not unanimous. In Arab lore the Banu Hilal's leader Abu Zayd al-Hilali is a hero; he enjoys a victory parade in Tunis where he is made lord of al-Andalus, according to the folk epic Taghribat Bani Hilal. The Banu Hilal came from the tribal confederacy Banu 'Amir, located mostly in southwest Arabia.
In Tunisia as the Banu Hilali tribes looted the rural areas, the local sedentary populace were forced to take refuge in the main coastal cities as well as in fortified towns in northern Tunisia (Such as Tunis, Sfax, Mahdia, Bizerte...). During this time, Tunisia underwent rapid urbanisation as famines depopulated the countryside and industry shifted from agriculture to manufactures. The prosperous agriculture of central and northern Ifriqiya gave way to pastoralism for a time; consequently the economic well-being went into steep decline.
Even after the fall of the Zirids, the Banu Hilal were a source of disorder, as in the 1184 insurrection of the Banu Ghaniya. These rough Arab newcomers, however, did constitute a second large wave of Arab immigration into Ifriqiya, and thus accelerated the process of Arabization. Use of the Berber languages decreased in rural areas as a result of the Bedouin ascendancy. Substantially weakened, Sanhaja Zirid rule lingered, with civil society disrupted, and the regional economy now in chaos.

## Normans in coastal Tunisia

Normans from Sicily raided the east coast of Ifriqiya for the first time in 1123. After some years of attacks, in 1148 Normans under George of Antioch conquered all the coastal cities of Tunisia: Bona (Annaba), Mahdia, Sfax, Gabès, and Tunis.
   "By the early 12th century, Sicily and Ifrīqiya were linked through their economic interdependence. From 1135, Al-Mahdīya became a de facto Sicilian protectorate, and in the 1140s much of coastal Ifrīqiya was subjected to Roger II's overlordship while the Zirid state ceased to exist."
Indeed, the Norman king Roger II of Sicily was able to create a coastal dominion of the area between Bona and Tripoli that lasted from 1135 to 1160 and was supported mainly by the last local Christian communities.
These communities, usually Christian North African populations (Roman Africans), holding to their religion since the Roman Empire, still spoke the African Romance in a few places like Gabès and Gafsa: the most important testimony of the existence of the African Romance comes from the 12th-century Arab geographer Muhammad al-Idrisi, who wrote that the people of Gafsa (in central-south Tunisia) used a language that he called al-latini al-afriqi ("the Latin of Africa";).

## Berber Islamic movements

In the medieval Maghrib, among the Berber tribes, two strong religious movements arose one after the other: the Almoravids (1056–1147), and the Almohads (1130–1269). Professor Jamil Abun-Nasr compares these movements with the 8th-and-9th-century Kharijites in the Magrib including Ifriqiya: each a militant Berber movement of strong Muslim faith, each rebellious against a status quo of lax orthodoxy, each seeking to found a state in which "leading the Muslim good life was the professed aim of politics". These medieval Berber movements, the Almoravids and the Almohads, have been compared to the more recent Wahhabis, strict fundamentalists of Saudi Arabia.
The Almoravids [Arabic al-Murabitum, from Ribat, e.g., "defenders"] began as an Islamic movement of the Sanhaja Berbers, arising in the remote deserts of the southwest Maghrib. After a century, this movement had run its course, losing its cohesion and strength, thereafter becoming decadent. From their capital Marrakech the Almoravids had once governed a large empire stretching from Mauritania (south of Morocco) to al-Andalus (southern Spain), yet Almoravid rule had never reached east far enough to include Ifriqiya.
The rival Almohads were also a Berber Islamic movement, whose founder was from the Masmuda tribe. They defeated and supplanted the Amoravids and themselves established a large empire, which embraced the region of Ifriqiya, formerly ruled by the Zirids.

## Almohads (al-Muwahiddin)
### Mahdi of the Unitarians

The Almohad movement [Arabic al-Muwahhidun, "the Unitarians"] ruled variously in the Maghrib starting about 1130 until 1248 (locally in Morocco until 1275). This movement had been founded by Ibn Tumart (1077–1130), a Masmuda Berber from the Atlas Mountains of Morocco, who became the mahdi. After a pilgrimage to Mecca followed by study, he had returned to the Maghrib about 1218 inspired by the teachings of al-Ash'ari and al-Ghazali. A charismatic leader, he preached an interior awareness of the Unity of God. A puritan and a hard-edged reformer, he gathered a strict following among the Berbers in the Atlas, founded a radical community, and eventually began an armed challenge to the current rulers, the Almoravids (1056–1147).
Ibn Tumart the Almohad founder left writings in which his theological ideas mix with the political. Therein he claimed that the leader, the mahdi, is infallible. Ibn Tumart created a hierarchy from among his followers which persisted long after the Almohad era (i.e., in Tunisia under the Hafsids), based not only on a specie of ethnic loyalty, such as the "Council of Fifty" [ahl al-Khamsin], and the assembly of "Seventy" [ahl al-Saqa], but more significantly based on a formal structure for an inner circle of governance that would transcend tribal loyalties, namely, (a) his ahl al-dar or "people of the house", a sort of privy council, (b) his ahl al-'Ashra or the "Ten", originally composed of his first ten forminable followers, and (c) a variety of offices. Ibn Tumart trained his own talaba or ideologists, as well as his huffaz, who function was both religious and military. There is lack of certainty about some details, but general agreement that Ibn Tumart sought to reduce the "influence of the traditional tribal framework." Later historical developments "were greatly facilitated by his original reorganization because it made possible collaboration among tribes" not likely to otherwise coalesce. These organizing and group solidarity preparations made by Ibn Tumart were "most methodical and efficient" and a "conscious replica" of Medina in the time of Muhammad.
The mahdi Ibn Tumart also had championed the idea of strict Islamic law and morals displacing unorthodox aspects of Berber custom. At his early base at Tinmal, Ibn Tumart functioned as "the custodian of the faith, the arbiter of moral questions, and the chief judge." Yet evidently because of the narrow legalism then common among Maliki jurists and because of their influence in the rival Almoravid regime, Ibn Tumart opposed the Maliki school of law favoring instead the Zahirite school.

### Empire of a unified Maghrib

Following the Mahdi Ibn Tumart's death, Abd al-Mu'min al-Kumi (c. 1090 – 1163) circa 1130 became the Almohad caliph—the first non-Arab to take such title. Abd al-Mu'min had been one of the original "Ten" followers of Ibn Tumart. He immediately launched attacks on the ruling Almoravid and had wrestled Morocco away from them by 1147, suppressing subsequent revolts there. Then he crossed the straits, occupying al-Andalus (in southern Spain); yet Almohad rule there was uneven and divisive. Abd al-Mu'min spend many years "organizing his state internally with a view to establishing the government of the Almohad state in his family." "Abd al-Mu'min tried to create a unified Muslim community in the Maghrib on the basis of Ibn Tumart's teachings."
Meanwhile, the anarchy in Zirid Ifriqiya (Tunisia) made it a target for the Norman kingdom in Sicily, who between 1134 and 1148 had taken control of Mahdia, Gabès, Sfax, and the island of Jerba, all of which served as centers for commerce and trade. The only strong Muslim power then in the Maghreb was that of the newly emerging Almohads, led by their caliph a Berber Abd al-Mu'min. He responded with several military campaigns into the eastern Maghrib which absorbed the Hammaid and Zirid states, and removed the Christians. Thus in 1152 he first attacked and occupied Bougie (in eastern Algeria), ruled by the Sanhaja Hammadids. His armies next entered Zirid Ifriqiya, a disorganized territory, taking Tunis. His armies also besieged Mahdia, held by Normans of Sicily, compelling these Christians to negotiate their withdrawal in 1160. Yet Christian merchants, e.g., from Genoa and Pisa, had already arrived to stay in Ifriqiya, so that such a foreign merchant presence (Italian and Aragonese) continued.
With the capture of Tunis, Mahdia, and later Tripoli, the Almohad state reached from Morocco to Libya. "This was the first time that the Maghrib became united under one local political authority." "Abd al-Mu'min briefly presided over a unified North African empire--the first and last in its history under indigenous rule". It would be the high point of Maghribi political unity. Yet twenty years later, by 1184, the revolt in the Balearic Islands by the Banu Ghaniya (who claimed to be heirs of the Almoravids) had spread to Ifriqiya and elsewhere, causing severe problems for the Almohad regime, on and off for the next fifty years.

### Religion and culture

Ibn Tumart had refused to recognize the fiqh of any established school of law. In practice, however, the Maliki school of law survived and by default worked at the margin. Eventually Maliki jurists came to be recognized in some official fashion, except during the reign of Abu Yusuf Ya'qub al-Mansur (1184–1199) who was loyal to Ibn Tumart's teachings. Yet the confused status continued to exist on and off, although at the end for the most part to function poorly. After of century of such oscillation, the caliph Abu al-'Ala Idris al-Ma'mun broke with the narrow ideology of the Almohad regimes (first articulated by the mahdi Ibn Tumart); circa 1230, he affirmed the reinstitution of the then-reviving Malikite rite, perennially popular in al-Maghrib.
The Muslim philosophers Ibn Tufayl (Abubacer to the Latins) of Granada (died 1185), and Ibn Rushd (Averroës) of Córdoba (1126–1198), who was also appointed a Maliki judge, were dignitaries known to the Almohad court, whose capital became fixed at Marrakech. The Sufi master theologian Ibn 'Arabi was born in Murcia in 1165. Under the Almohads architecture flourished, the Giralda being built in Seville and the pointed arch being introduced.
"There is no better indication of the importance of the Almohad empire than the fascination it has exerted on all subsequent rulers in the Magrib." It was an empire Berber in its inspiration, and whose imperial fortunes were under the direction of Berber leaders. The unitarian Almohads had gradually modified the original ambition of strictly implementing their founder's designs; in this way the Almohads were similar to the preceding Almoravids (also Berber). Yet their movement probably worked to deepen the religious awareness of the Muslim people across the Maghrib. Nonetheless, it could not suppress other traditions and teachings, and alternative expressions of Islam, including the popular cult of saints, the sufis, as well as the Maliki jurists, survived.
The Almohad empire (like its predecessor the Almoravid) eventually weakened and dissolved. Except for the Muslim Kingdom of Granada, Spain was lost. In Morocco, the Almohads were to be followed by the Merinids; in Ifriqiya (Tunisia), by the Hafsids (who claimed to be the heirs of the unitarian Almohads).

## Hafsid dynasty of Tunis

The Hafsid dynasty (1230–1574) succeeded Almohad rule in Ifriqiya, with the Hafsids claiming to represent the true spiritual heritage of its founder, the Mahdi Ibn Tumart (c. 1077 – 1130). For a brief moment a Hafsid sovereign would be recognized as the Caliph of Islam. Tunisia under the Hafsids would eventually regain for a time cultural primacy in the Maghrib.

### Political chronology

Abu Hafs 'Umar Inti was one of the Ten, the crucial group composed of very early adherents to the Almohad movement [al-Muwahhidun], circa 1121. These Ten were companions of Ibn Tumart the Mahdi, and formed an inner circle consulted on all important matters. Abu Hafs 'Umar Inti, wounded in battle near Marrakesh in 1130, was for a long time a powerful figure within the Almohad movement. His son 'Umar al-Hintati was appointed by the Almohad caliph Muhammad an-Nasir as governor of Ifriqiya in 1207 and served until his death in 1221. His son, the grandson of Abu Hafs, was Abu Zakariya.
Abu Zakariya (1203–1249) served the Almohads in Ifriqiya as governor of Gabès, then in 1226 as governor of Tunis. In 1229 during disturbances within the Almohad movement, Abu Zakariya declared his independence, having the Mahdi's name declared at Friday prayer, but himself taking the title of Amir: hence, the start of the Hafsid dynasty (1229–1574). In the next few years he secured his hold on the cities of Ifriqiya, then captured Tripolitania (1234) to the east, and to the west Algiers (1235) and later Tlemcen (1242). He solidified his rule among the Berber confederacies. Government structure of the Hafsid state followed the Almohad model, a rather strict hierarchy and centralization. Abu Zakariya's succession to the Almohad movement was acknowledged as the only state maintaining Almohad traditions, and was recognized in Friday prayer by many states in Al-Andalus and in Morocco (including the Merinids). Diplomatic relations were opened with Frederick II of Sicily, Venice, Genoa, and Aragon. Abu Zakariya the founder of the Hafsids became the foremost ruler in the Maghrib.
For an historic moment, the son of Abu Zakariya and self-declared caliph of the Hafsids, al-Mustansir (r.1249-1277), was recognised as Caliph by Mecca and the Islamic world (1259–1261), following termination of the Abbasid caliphate by the Mongols in 1258. Yet the moment passed as a rival claimant to the title advanced; the Hafsids remained a local sovereignty.
Since their origins with Abu Zakariya the Hafsids had represented their regime as heir to the Almohad movement founded by the Mahdi Ibn Tumart, whose name was invoked during Friday prayer at emirate mosques until the 15th century. Hafsid government was accordingly constituted after the Almohad model created by the Mahdi, i.e., it being rigorous hierarchy. The Amir held all power with a code of etiquette surrounding his person, although as sovereign he did not always hold himself aloof. The Amir's counsel was the Ten, composed of the chief Almohad shaiks. Next in order was the Fifty assembled from petty shaiks, with ordinary shaiks thereafter. The early Hafsids had a censor, the mazwar, who supervised the ranking of the designated shaiks and assigned them to specified categories. Originally there were three ministers [wazir, plural wuzara]: of the army (commander and logistics); of finance (accounting and tax); and, of state (correspondence and police). Over the centuries the office of Hajib increased in importance, at first being major-domo of the palace, then intermediary between the Amir and his cabinet, and finally de facto the first minister. State authority was publicly asserted by impressive processions: high officials on horseback parading to the sound of kettledrums and tambors, with colorful silk banners held high, all in order to cultivate a regal pomp. In provinces where the Amir enjoyed recognized authority, his governors were usually close family members, assisted by an experienced official. Elsewhere provincial appointees had to contend with strong local oligarchies or leading families. Regarding the rural tribes, various strategies were employed; for those on good terms their tribal shaik might work as a double agent, serving as their representative to the central government, and also as government agent to his fellow tribal members.
In 1270 King Louis IX of France, whose brother was the king of Sicily, landed an army near Tunis; disease devastated their camp. Later, Hafsid influence was reduced by the rise of the Moroccan Marinids of Fez, who captured and lost Tunis twice (1347, and 1357). Yet Hafsid fortunes would recover; two notable rulers being Abu Faris (1394–1434) and his grandson Abu 'Amr 'Uthman (r. 1435–1488).
Toward the end, internal disarray within the Hafsid dynasty created vulnerabilities, while a great power struggle arose between Spaniard and Turk over control of the Mediterranean. The Hafsid dynasts became pawns, subject to the rival strategies of the combatants. By 1574 Ifriqiya had been incorporated into the Ottoman Empire.

### Society and culture

After an hiatus under the Almohads, the Maliki madhhab (school of law) resumed its full traditional jurisdiction over the Maghrib. During the 13th century, the Maliki school had undergone substantial liberalizing changes due in part to Iraqi influence. Under Hafsid jurisprudents the concept of maslahah or "public interest" developed in the operation of their madhhab. This opened up Maliki fiqh to considerations of necessity and circumstance with regard to the general welfare of the community. By this means, local custom was admitted in the Sharia of Malik, to become an integral part of the legal discipline. Later, the Maliki theologian Muhammad ibn 'Arafa (1316–1401) of Tunis studied at the Zaituna library, said to contain 60,000 volumes.
Bedouin Arabs continued to arrive into the 13th century. With their tribal ability to raid and war still intact, they remained problematic and influential. The Arab language came to be predominant, except for a few Berber-speaking areas, e.g., Kharijite Djerba, and the desert south. An unfortunate divide developed between the governance of the cities and that of the countryside; at times the city-based rulers would grant rural tribes autonomy ('iqta') in exchange for their support in intra-maghribi struggles. Yet this tribal independence of the central authority meant also that when the center grew weak, the periphery might still remain strong and resilient.
From al-Andalus Muslim and Jewish migration continued to come into Ifriqiya, especially after the fall of Granada in 1492, the last Muslim state ruling on the Iberian peninsula. These newly arriving immigrants brought infusions of their highly developed arts. The well-regarded Andalusian traditions of music and poetry are found discussed by Ahmad al-Tifashi (1184–1253) of Tunis, in his Muta'at al-Asma' fi 'ilm al-sama' [Pleasure to the Ears, on the Art of Music], in volume 41 of his encyclopedia.
As a result of the initial prosperity, Al-Mustansir (r.1249-1277) had transformed the capital city of Tunis, constructing a palace and the Abu Fihr park; he also created an estate near Bizerte (said by Ibn Khaldun to be without equal in the world). Education was improved by the institution of a system of madrasah. Sufism, e.g., Sidi Bin 'Arus (d. 1463 Tunis) founder of the Arusiyya tariqah, became increasingly prominent, forming social links between the city and countryside. The Sufi shaikhs began to assume the religious authority once held by the unitarian Almohads, according to Abun-Nasr. Poetry blossomed, as did architecture. For the moment, Tunisia had regained cultural leadership of the Maghrib.

### Commerce and trade

Tunisia under the early Hafsids, as well as the entire Maghrib, enjoyed a general prosperity due to the rise of the Saharan-Sudanese trade. Perhaps more important was the increase in Mediterranean commerce including trade with Europeans. Across the region, the repetition of buy and sell dealings with Christians led to the eventual development of trading practices and structured shipping arrangements that were crafted to ensure mutual security, customs revenue, and commercial profit. It was possible for an arriving ship to deliver its goods and pick-up the return cargo in several days time. Christian merchants of the Mediterranean, usually organized by their city-of-origin, set up and maintained their own trading facilities (a funduq) in these North African customs ports to handle the flow of merchandise and marketing.
The principal maritime customs ports were then: Tunis, Sfax, Mahdia, Jerba, and Gabés (all in Tunisia); Oran, Bougie (Béjaïa), and Bône (Annaba) (in Algeria); and Tripoli (in Libya). At such ports generally, the imports were off loaded and transferred to a customs area from where they were deposited in a sealed warehouse, or funduq, until the duties and fees were paid. The amount imposed varied, usually five or ten percent. The Tunis customs service was a stratified bureaucracy. At its head was often a member of the ruling nobility or musharif, called al-Caid, who not only managed the staff collecting duties but also might negotiate commercial agreements, conclude treaties, and act as judge in legal disputes involving foreigners.
Tunis exported grain, dates, olive oil, wool and leather, wax, coral, salt fish, cloth, carpets, arms, and also perhaps black slaves. Imports included cabinet work, arms, hunting birds, wine, perfumes, spices, medical plants, hemp, linen, silk, cotton, many types of cloth, glass ware, metals, hardware, and jewels.
Islamic law during this era had developed a specific institution to regulate community morals, or hisba, which included the order and security of public markets, the supervision of market transactions, and related matters. The urban marketplace [Arabic souk, pl. iswak] was generally a street of shops selling the same or similar commodities (vegetables, cloth, metalware, lumber, etc.). The city official charged with these responsibilities was called the muhtasib.
To achieve public order in the urban markets, the muhtasib would enforce fair commercial dealing (merchants truthfully quoting the local price to rural people, honest weights and measures, but not quality of goods nor price per se), keep roadways open, regulate the safety of building construction, and monitor the metal value of existing coinage and the minting of new coin (gold dinars and silver dirhems were minted at Tunis). The authority of the muhtasib, with his group of assistants, was somewhere between a qadi (judge) and the police, or on other occasions perhaps between a public prosecutor (or trade commissioner) and the mayor (or a high city official). Often a leading judge or mufti held the position. The muhtasib did not hear contested litigation, but nonetheless could prescribe the pain and humiliation of up to 40 lashes, remand to debtor's prison, order a shop closed, or expel an offender from the city. However, the civic authority of the muhtasib did not extend into the countryside.
Beginning in the 13th century, from al-Andalus came Muslim and Jewish immigrants with appreciated talents, e.g., trade connections, agricultural techniques, manufacture, and arts (see below, Society and culture). Yet unfortunately general prosperity was not steady over the centuries of Hafsid rule; there was a sharp economic decline starting in the mid-fourteenth century due to a variety of factors (e.g., agriculture, and the Sahara trade). Under the amir Abu al-'Abbas (1370–1394), Hafsid participation in the Mediterranean trade began to decline, while early corsair raiding activity commenced.

## Ibn Khaldun
### Life and career

A major social philosopher, Ibn Khaldun (1332–1406) is recognized as a pioneer in sociology, historiography, and related disciplines. Although having Yemeni ancestry, his family enjoyed centuries-long residency in al-Andalus before leaving in the 13th century for Ifriqiyah. As a native of Tunis, he spent much of his life under the Hafsids, whose regime he served on occasion.
Ibn Khaldun entered into a political career early on, working under a succession of different rulers of small states, whose designs unfolded amid shifting rivalries and alliances. At one point he rose to vizier; however, he also spent a year in prison. His career required several relocations, e.g., Fez, Granada, eventually Cairo where he died. In order to write he retired for a while from active political life. Later, after his pilgrimage to Mecca, he served as Grand Qadi of the Maliki rite in Egypt (he was appointed and dismissed several times). While he was visiting Damascus, Tamerlane took the city; this cruel conqueror interviewed the elderly jurist and social philosopher, yet Ibn Khaldun managed to escape back to his life in Egypt.

### Social philosophy

The history and historiography written by Ibn Khaldun was informed in theory by his learning as a faylasuf [philosopher]. Yet it was his participation in the small unstable governments of the region that inspired many of his key insights. His history seeks to account for the apparent cyclical progression of historical states of the Maghrib, whereby: (a) a new ruling association comes to power with strong loyalties, (b) which over the course of several generations fall apart, (c) leading to the collapse of the ruling strata. The social cohesion necessary for the group's initial rise to power, and for the group's ability to maintain it and exercise it, Ibn Khaldun called Asabiyyah.
His seven-volume Kitab al-'Ibar [Book of Examples] (shortened title) is a telescoped "universal" history, which concentrates on the Persian, Arab, and Berber civilizations. Its lengthy prologue, called the Muqaddimah [Introduction], presents the development of long-term political trends and events as a field for the study, characterizing them as human phenomena, in quasi-sociological terms. It is widely considered to be a gem of sustained cultural analysis. Unfortunately Ibn Khaldun did not attract sufficient interest among local scholars, his studies being neglected in Ifriqiyah; however, in the Persian and Turkish worlds he acquired a sustained following.
In the later books of the Kitab al-'Ibar, he focuses especially on the history of the Berbers of the Maghrib. The perceptive Ibn Khaldun in his narration eventually arrives at historical events he himself witnessed or encountered. As an official of the Hafsids, Ibn Khaldun experienced first hand the effects on the social structure of troubled regimes and the long-term decline in the region's fortunes.