# Maghrawa

The Maghrawa or Meghrawa (Arabic: المغراويون) were a large Berber tribal confederation in North Africa. They were the largest branch of the Zenata confederation. Their traditional territories around the time of Muslim expansion into the Maghreb in the 7th century were around present-day northeastern Algeria. They ruled parts of the western Maghreb on behalf of the Umayyad Caliphate of Cordoba at the end of the 10th century and during the first half of the 11th century.

## Origins

The origins of the Maghrawa are uncertain. Ibn 'Abd al-Barr, an 11th-century writer, claimed that they arrived to the Maghreb in ancient times. Medieval Berber writers traced the ancestry of the Maghrawa to a leader named Maghrāw. According to Ibn Khaldun (d. 1406), they were related to the Banu Ifran, the Banu Jarawa, and the Banu Irniyan. Several tribes descend from the Maghrawa, including the Bani bou Said, Bani Ilit (Ilent), Bani Zendak, Bani Urac (Urtezmir, Urtesminn), Bani Urcifan, Bani Laghouat, Bani Righa, Bani Sidi Mansour (Bani Mansour), A. Lahsen, etc.
The Maghrawa traditionally occupied the area between Algiers, Cherchell, Ténès, Chlef, Miliana and Médéa. Historical sources indicate that their homeland was centered on the Chélif, in a region probably between the Ouarsenis to the south, the Mediterranean Sea to the north and Tlemcen to the west. In antiquity, Pliny the Elder and Ptolemy each mention a tribe named Macurebi or Makkhourebi, which some scholars have equated to the Maghrawa. If true, this makes the Maghrawa one of the few Berber tribes mentioned in ancient Greek and Latin sources. Pliny places them east of Icosium (present-day Algiers), while Ptolemy places them some of them along or east of the Draa River in present-day Morocco and others near present-day Chlef.

## History
### Early history

The Maghrawa occupied part of present-day Algeria at the time of the early Muslim conquests. According to Ibn Khaldun, they had been forced to convert to Christianity under Roman rule. They were one of the first Berber tribes to convert to Islam upon its arrival in the 7th century. The Maghrawa were initially led by the Banu Khazar family who lived in the first half of the 8th century and took control of a large part of the central Maghreb after the Kharijite revolts (circa 740). The Maghrawa role in the Kharijite revolt is known only from a tradition quoted by Ibn Khaldun and is not mentioned in any Arabic sources. His son, Muhammad ibn Khazar, defeated the Banu Ifran and captured Tlemcen circa 788, before submitting to the Idrisids sometime between 789 and 791 and becoming their ally. The latter's grandson, also named Muhammad ibn Khazar, allied himself with the Umayyads of Córdoba in Al-Andalus (present-day Spain and Portugal) and resisted the Fatimids for most of his life, embroiling the Maghrawa in the conflict between these two powers that played out in present-day Morocco and Algeria. Over the following decades, the two sides both suffered various victories and reversals. Muhammad ibn Khazar himself switched allegiances several times when the circumstances required, although his son al-Khayr, who also held territories in the central Maghreb, remained largely loyal to the Umayyads. Muhammad ibn Khazar eventually died in 961, reportedly over a hundred years old.
After his death, the Maghrawa continued to resist the Fatimids under the leadership of his grandson, Muhammad ibn al-Khay, son of al-Khayr. The latter had previously cultivated good relations with Abd ar-Rahman III (d. 961), the Umayyad caliph in Córdoba, who had appointed him governor of Fez in 955–6. He continued to serve Abd ar-Rahman III's successor, al-Hakam II (d. 976). In 971, a major confrontation took place between the Maghrawa and the Zirids, a Sanhaja clan led by Ziri ibn Manad, vassal of the Fatimids. In February 971, most likely near Tlemcen, the Maghrawa were severely defeated. Muhammad ibn al-Khayr committed suicide to avoid capture. His son, al-Khayr, took up the leadership role and allied himself with a Fatimid governor, Ja'far ibn 'Ali ibn Ḥamdun, who defected to the Umayyad side. With their combined forces, they won a major victory. Pressured by another Fatimid army, however, the majority of the Maghrawa left the central Maghreb and migrated into the Maghreb al-Aqsa (present-day Morocco), where they settled across the region.

### In the western Maghreb

In 976–7, a Maghrawa chief named Khazrun ibn Fulful ibn Khazar conquered Sijilmasa from the Banu Midrar, and in 980 were able to drive the Miknasa out of Sijilmasa as well. Khazrun sent the head of the last Midrarid ruler to Córdoba, whose rulers subsequently appointed him and his descendants, the Banu Khazrun, governors of Sijilmasa on behalf of the Umayyads.
Other branches of the Maghrawa founded small kingdoms or principalities in the region around the same period. One branch of the family descended from the Banu Khazar settled in Aghmat to the south, ruling there until the Almoravid conquest circa 1059. Another descendant of the Banu Khazar, identified as Muqatil, established himself in the Sous valley. Very little is known about either of these two branches.
Between 979 and 983, the Zenata were briefly driven out of Fez, Sijilmasa, and much of the surrounding regions during a major expedition by Buluggin ibn Ziri, the new Zirid ruler.
The Maghrawa reached their peak under Ziri ibn Atiyya (d. 1001), who achieved supremacy in Fez under Umayyad suzerainty, and expanded their territory at the expense of the Banu Ifran in the northern Maghreb – whose alliances had shifted often between the Fatimids and the Umayyads of Córdoba. Ziri ibn Atiyya conquered as much as he could of what is now northern Morocco and was able to achieve supremacy in Fez by 987. In that same year, Ibn Abi 'Amir al-Mansur – the regent of Caliph Hisham II and de facto ruler of the Caliphate of Córdoba – formally appointed Ziri as amir of the Maghreb on his behalf. Fez became his capital and generally remained under the control of his successors until the Almoravid conquest of the 11th century.
In 989, Ziri defeated his enemy Abu al-Bahār, which made him ruler from the Zab to the Sous, achieving supremacy in the western Maghreb by 991. In 993, he was invited to Córdoba by Ibn Abi 'Amir al-Mansur. Ziri brought many gifts and al-Mansur housed him in a lavish palace, but Ziri soon returned to North Africa. Meanwhile, his rival from the Banu Ifran, Yaddū ibn Ya'lā, had taken advantage of his absence and managed to capture Fez, which Ziri reconquered after a bloody struggle. A period of peace followed, in which Ziri founded the city of Oujda in 994 and made it his new capital and fortress. He likely intended to expand his power to the central Maghreb and the position of Oujda, further west, was more appropriate for this goal than Fez.
However, Ziri was loyal to the Umayyad caliphs in Cordoba and increasingly resented the way that Ibn Abi 'Amir was holding Hisham II captive while progressively usurping his power. In 997, Ziri rejected Ibn Abi 'Amir's authority and declared himself a direct supporter of Caliph Hisham II. Ibn Abi 'Amir sent an invasion force to Morocco. After three unsuccessful months, Ibn Abi 'Amir's army was forced to retreat to the safety of Tangiers, so Ibn Abi 'Amir sent a powerful reinforcements under his son Abd al-Malik. The armies clashed near Tangiers, and in this battle, Ziri was stabbed by an African soldier who reported to Abd al-Malik that he had seriously wounded the Zenata leader. Abd al-Malik pressed home the advantage, and the wounded Ziri fled, hotly pursued by the Caliph's army. The inhabitants of Fez would not let him enter the city, but opened the gates to Abd al-Malik on 13 October 998. Ziri fled to the Sahara, where he rallied the Zenata tribes and overthrew the unpopular remnants of the Idrisid dynasty at Tiaret. He was able to expand his territory to include Tlemcen and other parts of western Algeria, this time under Fatimid protection. Ziri died in 1001 of the after-effects of the stab wounds.
After Ziri's death, his son al-Mu'izz was proclaimed his successor as leader of the Maghrawa in northern Morocco. He did not share his father's hostility to Córdoba and al-Mansur had already appointed him governor of Fez on behalf of the Umayyads in 999–1000. Al-Mansur's son and successor, Abd al-Malik al-Muzaffar, confirmed him as governor of Fez and the Maghreb al-Aqsa in 1002–3 and again in 1006, with the exception of Sijilmasa, which was left under the rule of the Banu Khazrun. Al-Mu'izz's reign in Fez marked a period of relative peace. He also managed to remove Zirid rule in Tlemcen, where he installed one of his relatives, Ya'la (a descendant of al-Khayr), as governor. Ya'la's descendants continued to rule Tlemcen after him, though remaining loyal to al-Mu'izz.
Al-Mu'izz died in 1026 or 1030 and was succeeded by his paternal cousin, Hamama ibn al-Mu'izz ibn 'Atiya. Al-Mu'izz had already appointed the latter as governor of Fez before his death. Hamama strengthened his relations with Córdoba but in 1032–3 he became embroiled in war with the rival Banu Ifran leader, Abu al-Kamal Tamim ibn Ziri, based in Chellah. Abu al-Kamal Tamim captured Fez, forcing Hamama to flee east to Oujda and Ténès. In 1037–8, after gathering new forces, Hamama expelled the Banu Ifran and reclaimed Fez. In 1038–9, he attacked the Hammadids, a Sanhaja dynasty related to the Zirids. The Hammadid ruler, al-Qa'id, met with Hamama and paid the Maghrawa troops to defect. Hamama, fearing the outcome, fled back to Fez and declared his submission to al-Qa'id. He died sometime between 1039 and 1042.
He was succeeded by his son Dunas, who spent much of his reign improving the city of Fez, whose commercial importance was growing. After his death in 1059, his son al-Futuḥ succeeded him but the succession was contested by his brother Ajisa. The two brothers each took control of different parts of Fez and warred with each other for three years, until al-Futuḥ emerged victorious in 1062. Al-Futuḥ only ruled briefly, being driven from Fez in that same year by the Hammadid ruler Buluggin ibn Muhammad, who briefly occupied the city. After this, the Maghrawa appointed one of Ziri ibn Atiyya's descendants, Mu'annaṣir (or Mu'anṣar), as ruler.
By the mid 11th century, the Maghrawa still controlled most of Morocco, notably most of the Sous and Draa River area as well as Aghmat, Fez and Sijilmasa. As the Almoravids expanded northward during this period, the Maghrawa were their main opponents in this region. As Zenata power declined, the leaders of the Magharawa and Banu Ifran became more oppressive and violent, with some historical chronicles claiming that the local population welcomed the arrival of the Almoravids. The latter eventually overcame the Zenata rulers in the western Maghreb during the second half of the 11th century. Varying sources date their capture of Fez to 1069 or some time later in the 1070s. Mu'annaṣir, the last Maghrawa ruler of Fez, attempted to resist the Almoravid siege of the city but died in the process. His son Tamim was appointed to replace him but he was executed when the Almoravids captured the city soon after. Many of the Maghrawa and other Zenata in the city were slaughtered in the aftermath. The remaining Maghrawa fled east and north, until the Almoravids expanded in these directions as well.
Meanwhile, in Tlemcen, the descendants of Ya'la had cultivated friendly relations with the Hammadids during the early 11th century. This allowed them to rule an effectively independent kingdom until the 1050s, when they came into conflict with some of the Banu Hilal tribes arriving from the east, who took over much of the countryside. The Maghrawa amir at this time, Bakhti, rallied the other Zanata tribes in the region and fought a prolonged war with the Zughba, one of the Hilalian tribes, who allied themselves with the Hammadids. Bakhti died at some point during this period and was succeeded by his son al-Abbas, who held onto Tlemcen until the Almoravids arrived. The latter captured the town towards 1080, executing al-Abbas and killing many of the Maghrawa inside the city.

### Later history

Despite the Almoravid conquest, various groups of Maghrawa continued to live in various parts of Morocco until at least the 14th century, when they are mentioned by sources such as Ibn Khaldun. Additionally, the minority of Maghrawa tribes who had not left the central Maghreb with al-Khayr ibn Muhammad ibn al-Khayr after 971 remained in the Chélif region, even under Almoravid rule. They became important again for a time during the 14th century, when their main city was Timzaghat (or Timzurat). They unsuccessfully attempted to throw off the authority of the Zayyanid sultans in Tlemcen on several occasions around the mid-century until their final defeat in 1372, after which many of them left the region.

## Maghrawa society

The Zenata seized some of the best lands of the Masmuda, and the Maghrawa became the dominant military caste over those they conquered.
According to Ibn Abi Zar, the chronicler of Fez, the Maghrawa improved the walls, gates and mosques of Fez, and under their rule, the city enjoyed peace. Its people were busy with construction activities and the town expanded. Security and prosperity continued up until shortly before the arrival of the Almoravids. Overall, the mass migration of the Banu Ifran and Maghrawa because of the Sanhaja expansion caused political and ethnic revolution in Morocco.

## Maghrawid leaders

The Maghrawa were led by the Banu Khazar family, named after Khazar ibn Ḥafṣ ibn Ṣulat ibn Wazmār ibn Maghraw, who lived in the first half of the 8th century. His son, Muhammad ibn Khazar, continued to lead after him. Muhammad's son, named Khazar like his grandfather, had a son who was also named Muhammad and was thus also known as Muhammad ibn Khazar. The latter died in 961, reportedly over a hundred years old. He had three sons from whom many future Maghrawa leaders descended: Falful, al-Khayr, and Hamza.
Starting with Ziri Ibn Atiyya, the Maghrawa dynasty that ruled Fez and the surrounding region consisted of two family branches descended from the sons of Atiya. Atiya was a descendant of Muhammad Ibn Khazar via his son Falful. One branch descended from Ziri ibn Atiya and the other from his brother, Al-Mu'izz ibn Atiya. The rulers are listed here in chronological order:
* Ziri ibn Atiyya, r. 988–1001.
* al-Mu'izz ibn Ziri, r. 1001–1026.(Another source also claims he died in 1030 instead.)
* Hammama ibn al-Mu'izz (son of al-Mu'izz ibn Atiya and cousin of al-Mu'izz ibn Ziri), r. 1026–1039. (He may also have died as late as 1042 instead.)
* Abu al-Attaf Dunas ibn Hamama, r. 1039–1059.
** Hammad ibn al-Mu'izz (son of al-Mu'izz ibn Ziri), challenged Abu al-Attaf Dunas and died in 1043.
* Futuh ibn Dunas, r. 1059–1062.
** Ajisa ibn Dunas (Futuh's brother), who controlled a part of Fez, fought with his brother and was killed by him in 1061.
* Mu'annasir ibn Hammad (descended from Ziri's line), r. 1062–1067.
* Tamim, r. 1067–1069.
Tamim was the last Maghrawa ruler to hold power before the Almoravids took over Fez. There is uncertainty about the chronology of Almoravid conquests in this region and therefore different authors give different dates for the Almoravid conquest of Fez.