The Idrisid Dynasty and the Geopolitical Landscape of the Far Maghrib: A Historical Analysis



A richly detailed, sepia-toned illustration of 10th-century scholars in Fez examining Arabic manuscripts and an Idrisid genealogical chart titled “The Prophetic, and Idrisid, Descendants Lineage.” Seated around a wooden desk in an ornate Maghribi library, the scholars study ancient documents alongside astrolabes and maps of North Africa marking Fez, Meknes, Tlemcen, and Sijilmasa. Through an archway, the Qarawiyyin Mosque’s minaret rises above the city, while an illustrated map and banners representing Córdoba and the Abbasids evoke the political pressures surrounding the Idrisid legacy. The scene combines intricate ink drawing, faded watercolor, geometric architecture, and the aged texture of an archival manuscript.

Scholars of 10th-century Fez examine the genealogical legacy of the Idrisid dynasty, tracing the Prophetic lineage through ancient manuscripts and historical maps. Amid the intellectual traditions of the Maghrib, their work reflects the enduring relationship between genealogy, scholarship, and the political history of North Africa.: The Idrisid Dynasty and the Geopolitical Dynamics of the Far Maghrib

Introduction 

​The historical trajectory of the early Islamic Far Maghrib is characterized by a complex interplay of dynastic state-formation, tribal alliances, and intense ideological and geopolitical competition. At the center of this dynamic stood the Idrisid Dynasty—founded by the Alid house—which established a distinct political and religious center in Fez, serving as the capital of the Hashemite Caliphate in the region. As detailed in historical chronicles, the consolidation of Idrisid rule involved intricate territorial distributions among the progeny of Imam Idris II, establishing administrative and tribal spheres of influence that stretched from Tangier and the Sousse region to Tlemcen and the Rif.

​However, this nascent Islamic polity soon found itself situated precariously between two major rival powers: the Abbasid Caliphate—operating via its Ifriqiyan proxies, the Aghlabids—and the Umayyads of Cordoba in al-Andalus. This geopolitical vulnerability was compounded by internal fissures, succession disputes, and the aggressive expansionist campaigns of the Ubaidid (Fatimid) movement through their Zenata allies, notably Masalah ibn Habus and Musa ibn Abi al-Afiya. The subsequent decades witnessed severe political fragmentation, prolonged sieges, and the systematic persecution of the Idrisid Ahl al-Bayt. Yet, despite severe destitution, political displacement, and the ultimate eclipse of their sovereign rule, the resilience of the Idrisid leadership and the enduring loyalties of regional Berber tribes ensured the preservation of their lineage and a lasting spiritual and political legacy within the historiography of North Africa.  

And Muhammad was older than his brothers in age, and therefore he succeeded his father in the Imamah shortly after him, and for this reason, he was pledged allegiance to the Caliphate on the 15th of Jumada al-Akhirah, which is three days after his father's death.

​Biography of Imam Muhammad ibn Idris II

​He is Imam Muhammad ibn Idris II ibn Idris I ibn Abdullah al-Kamil ibn al-Hasan al-Muthanna ibn al-Hasan al-Sibt ibn Ali and Fatimah al-Zahra, daughter of the Messenger of Allah, peace and blessings be upon him. His mother was a free woman from the nobles of Nafza, from the tribe of his grandmother Kanzah al-Nafziyah. Among his descriptions were that he was of brown complexion, handsome stature, pleasant face, young age, and curly hair. When matters settled for him after the pledge of allegiance, he divided the Maghrib between his brothers by the advice of his grandmother Kanzah, allocating:

  1. ​Al-Qasim: Tangier, Ceuta, As-Sani' (Qasr Masmuda / Al-Qasr al-Sagheer), Al-Basra, the territory of Hajar an-Nasr, Tetouan, and adjacent tribes and lands.

  1. ​Umar: Tiksas, Targha, and surrounding tribes of Ghomara and Sanhaja.

  1. ​Dawud: The lands of Hawara, Tasul, Taza, and surrounding tribes of Miknasa and Ghiatha.

  1. ​Yahya: Asilah, Larache, Qasr al-Kabeer, and adjacent lands of Wargha.

  1. ​Isa: Sala (Salé), Shella (which is in ruins near Rabat on the Bu Regreg river), Tamasna, Azemmour, and adjacent Tamasna tribes.

  1. ​Hamzah: The city of Volubilis (Walili) and its districts.

  1. ​Ahmad: The city of Meknes, Tadla, and surrounding Fazaz tribes.

  1. ​Abdullah: Aghmat, the lands of Nafis, the Masmuda mountains, the land of Lamta, and Far Sousse (Al-Sus al-Aqsa).

​The rest were young children still under his care and the care of their grandmother Kanzah. Then Imam Muhammad passed away on the 15th of Jumada al-Akhirah in the year 221 AH, and his reign lasted 8 years and one month. He was buried beside the grave of his father and brother Umar, adjacent to the wall of the Sharif Mosque. He appointed his son Ali, nicknamed "Haidara", to the leadership of the Maghrib—this nickname being borrowed from the title of his grandfather Imam Ali, may Allah honor his face. He was pledged allegiance to the Caliphate shortly before his father's death, at the age of 9 years and four months, in the year 221 AH. He was the last of the Alawite (Alid) line to hold the Caliphate.

​Biography of Imam Ali Haidara

​He is Imam Ali, nicknamed Haidara, son of Muhammad ibn Idris II ibn Idris.

​...and they called it "Fez". When Imam Idris, may Allah be pleased with him, finished building the city, he moved to it with his entourage, settled it, and made it the seat of his kingdom and the capital of the Hashemite Caliphate in the Far Maghrib. In the year 197 AH, he set out to conquer the Masmuda tribes of the Nafis region—known today as the Sousse tribes—and the city of Aghmat, conquering all the Masmuda lands. Then he returned to Lamas and stayed there until the month of Muharram in the year 199 AH. Then he went out to conquer the Nafza tribes—known today as the Beni Iznasen tribes—and adjacent areas of Tlemcen, fighting them and entering the city of Tlemcen. He inspected its conditions, repaired its walls and main mosque, and manufactured a pulpit in it. Abu Marwan Abd al-Malik said: "I entered the mosque of Tlemcen in the year 255 AH, and I saw at the head of its pulpit a wooden board from the remains of an old pulpit on which was nailed and written: 'This is what was ordered by Idris ibn Idris ibn Abdullah al-Kamil ibn Hasan ibn al-Hasan ibn Ali, may Allah be pleased with them, in the month of Muharram of the year 199 AH'."

​Idris stayed there for 3 years, then returned to the city of Fez and remained there until he passed away, may Allah have mercy on him, in the year 213 AH at the age of 36. He was buried in the Sharif Mosque near its eastern wall. The correct view is that he was buried facing its qibla where he is to this day, and therefore visiting and praying for him should be done facing his noble face from behind the dome on the same street leading to Al-Qarawiyyin Mosque, which is correct. As for what the ignorant do inside the dome by entering under the cloth, speaking secretly, touching the grille, and the like, it is a reprehensible innovation. Al-Barnousi stated that Idris ibn Idris passed away in the city of Walili in the Zerhoun region on the night of the 12th of Jumada al-Akhirah, in the year 213 AH, and was buried next to his father's grave in the ribat of Walili. The cause of his death was that he ate grapes, choked on a seed, and died instantly. His reign in the Maghrib was 26 lunar years.

​The Household of Imam Idris II

​Imam Idris II left behind 12 male children, who are famously:

  1. ​Muhammad

  1. ​Abdullah

  1. ​Isa

  1. ​Idris

  1. ​Ahmad

  1. ​Ja'far

  1. ​Yahya

  1. ​Al-Qasim

  1. ​Umar

  1. ​Ali

  1. ​Dawud

  1. ​Hamzah

​Margin Note (Handwritten):

"The ones with verified descendants without dispute are Muhammad, Qasim, Umar, Ahmad, and Abdullah—five among whom is what was transmitted and recorded. As for Dawud, Yahya, and Hamzah, no descendants were mentioned for them. As for Idris, Ali, and Ja'far, it is mostly likely they died young. — The Author"

​...animals like wild beasts and hunting dogs on the first of Rabi' al-Awwal in the year 191 AH.

​The Founding of the City of Fez

​Then Imam Idris descended there and set up his buildings and domes at the location known today as Jarawah, then began building the wall, surrounding it with a fence of reed and wood, naming the place Jarawah. In the year 192 AH, he founded the Andalusian quarter, and in the year 193 he founded the Qarawiyyin quarter, built his dwellings there, and then moved to them. Then he encircled it with a wall, starting from the direction of the qibla, and built the mosque at the well square known as the Mosque of the Shaykhs, establishing the Friday prayer in it. Then he returned to the Qarawiyyin quarter, descended to a place known as Al-Qarmada, and built a dome over it. Then he began building the mosque known today as the Sharif Mosque, may Allah honor it by mentioning Him, and established the Friday prayer in it. Then he began building his residence—known now as Dar al-Qaytloun, inhabited by the Sharifian Juyutiyyin descendants. Then he built the Qaysariyyah next to the congregational mosque, and arranged markets around it on every side, telling those who built a place and planted it before the completion of the wall: "It is a gift for the sake of Allah."

​The Supplication of Mawlay Idris Upon Commencing Construction

​It is mentioned that when he wanted to start construction, he turned to Allah with his hands raised, saying in his supplication: "O Allah, make it a house of knowledge and jurisprudence, in which Your Book is recited, Your boundaries are upheld, and make its people steadfast on the Sunnah and the Jama'ah as long as you keep it." Then he took the pickaxe in his hand and began digging the foundation. The most appropriate account regarding the reason for naming it Fez is that a monk came to Mawlay Idris and asked him about the work they were doing. He informed him that he had begun building a city in this place. The monk told him that an ancient city existed here which was destroyed 17 centuries ago and was called Saf, but change its name.

​...the first. It says in Al-Istiqsa: He is the ancestor of the Alid Al-Alami scholars—the people of Jabal al-Ilm, among them the Mashishiyyin, the descendants of our master Abd al-Salam ibn Mashish, may Allah be pleased with him, the descendants of Sidi Muhammad ibn Yamlha, and the descendants of Sidi al-Hajj Musa al-Rida. Details about the Al-Alami Sharifs and their branches, along with their common origin, will be discussed. Due to his young age, his upbringing was undertaken by the retinue and the awliya among the Arabs and Berbers, who honored his custody and obedience, making his days the best of days. His mother's name was Ruqayyah, daughter of Ismail ibn Umayr ibn Mus'ab al-Azdi, who was an Arab. There appeared in him from intelligence, nobility, and virtue what his noble status and correct lineage required. He walked among the people with the biography of his father alone in religion, virtue, firmness, justice, establishing the truth, securing frontiers, and suppressing enemies. The Maghrib during his time was in security, ease, and prosperity. He passed away, may Allah have mercy on him, in the sacred month of Rajab in the year 234 AH, and his rule lasted about 13 lunar years. He did not appoint his son Mizwar, who was the conclusion of the Mashishian lineage from the children of Idris.

​Then this blessed lineage was followed by other rings of ascetics, saints, and qutbs (poles) of the gnostics of Allah until it reached the shining star and bright full moon, whom the people of his era nicknamed "The Comprehensive Sheikh" our master Abd al-Salam ibn Mashish, whose fame reached the ears of the Islamic world from East and West, Arabs and non-Arabs. Writers' pens will never stop researching his virtues and praising him. I imagine it is nothing but an extension of that light emanating from Fatimah al-Zahra, may Allah be pleased with her, expressing truly that secret which the Messenger of Allah, peace and blessings be upon him, deposited in her by the blessing of his supplication for her on the day she was wedded to the house of Ali ibn Abi Talib. After raising his head from prostration thanking Allah, the Messenger of Allah, peace and blessings be upon him, said to him: "May Allah bless both of you, bless in both of you, honor your grandfather, and bring forth from both of you much goodness," as preceded in her biography. That blessed lineage of Qutbs is the fruit of the answer to his supplication, peace and blessings be upon him. In a narration by Al-Nasa'i: "O Allah, bless both of them, and bless for them in their offspring."

​The Storms Experienced by the Idrisids

​As I was researching the catastrophes and events experienced by the Ahl al-Bayt in the East and West across the eras they passed through, it was not appropriate to expand on history, its conditions, and its men; rather, I took from each state what suited the general context.

​The young Idrisid state arose in the Maghrib between two great giants that dominated it: one in the East, whose evil emanated from the capital of the Islamic Caliphate in Baghdad and passed on its way through its transitional center in Ifriqiyyah (Kairouan), Tunisia; and the other centered in Cordoba in al-Andalus in western Europe. The Idrisid state stood between them like the tongue of a balance shifting between the weight of one pan and the other.

​The Ubaidid (Fatimid) Takeover of the Far Maghrib

​This was at the hands of their commander Masalah ibn Habus al-Miknasi, commander of Abdullah al-Shi'i. Mention has already been made of the Aghlabids, governors of Ifriqiyyah, and Ibrahim ibn al-Aghlab was the last of them, having inherited sovereignty for his offspring, and their rule continued until the end of the third century. It was overthrown at the hands of Abu Abdullah al-Muhtasib, the missionary of the Ubaidids. The reason for this was that Al-Muhtasib went on Hajj, met Kutama pilgrims from the people of the Maghrib, inclined towards them, and promised them the appearance of the Mahdi from the Ahl al-Bayt at their hands, with kingship and authority alongside him. They followed him in his opinion, accompanied him to their lands, and he assumed religious leadership over them, established the Shiite doctrine for them, and they followed him and held fast to his opinion. Then they pledged allegiance to his master Abdullah al-Mahdi, the first of the Ubaidid caliphs, who seized Ifriqiyyah in a long account. Then his ambition turned towards owning the Far Maghrib, so he invaded it at the hand of his commander.

​(1) Masalah ibn Habus al-Miknasi, ruler of Tahart (Algeria) and the Middle Maghrib, then marched to the Far Maghrib in the year 305 AH until he reached Fez. Yahya ibn Idris ibn Umar ibn Idris II—who was the governor of the Far Maghrib—came out to meet him amidst throngs of Arabs, Berbers, and clients. They met near Meknes, where Yahya was defeated and returned routed to the city of Fez. Then Masalah advanced to Fez and besieged it until he made peace with Yahya on condition of a monetary tribute paid to him and the pledge of allegiance to Abdullah al-Mahdi. Yahya accepted the condition, relinquished control of the Maghrib, executed his allegiance to Abdullah al-Mahdi, and Masalah appointed him over the governorate of Fez and its residence. He also appointed his cousin Musa ibn Abi al-Afiya al-Miknasi over all other lands of the Maghrib. Musa was the master of Tasul and Taza, and the senior leader of Miknasi in the Far Maghrib. He had served Masalah when he came to the Maghrib, became acquainted with him, exchanged gifts with him, and fought alongside him in all his wars in the Maghrib, so his standing with him improved, and he appointed him over all the Maghrib except for the city of Fez and its districts.

​...for he left it in the hands of Imam Yahya, and the Far Maghrib became subject to Ubaidid influence. The Idrisid state dissolved within their realm. It is stated in Al-Istiqsa, quoting Ibn Khaldun: Yahya was the center bead of the Idrisid household, their most eminent in dignity, most distant in renown, most just, most abundant in virtue, and most expansive in dominion. He was a jurist, a memorizer of Hadith, eloquent, clear in speech, a heroic, resolute, and decisive champion, possessing righteousness, religion, and piety. None of the Idrisids reached his stature in state and authority until the high waves of the Ubaidid sea—who rose in Africa—overwhelmed and drowned him. The commander of the Maghrib, Musa ibn Abi al-Afiya, after the return of his commander Masalah ibn Habus to Kairouan, whenever he wanted to display tyranny and autocracy in the Maghrib, Yahya overshadowed him by virtue of his lineage, nobility, excellence, and religion, cutting off all his desires for tyranny and prominence. This weighed heavily on his heart, and he seized the opportunity of the return of his commander Masalah from Kairouan for the second time in the year 309 AH to incite him against him until he poisoned his heart. When Masalah approached Fez, Yahya went out to meet and greet him among a group of his state's notables. They arrested them and him, chained him in iron, and advanced to Fez, entering it with Yahya bound on a camel before him. He confiscated his wealth and treasures, tortured him with all kinds of torture, and then exiled him to the surroundings of Asilah. His condition worsened and his supporters dispersed. He stayed with his paternal uncles in the Rif region for a period, where they supported him with their wealth to fix his condition and sustain him, but he refused submission and left them wanting Africa. Ibn Abi al-Afiya intercepted him on his way, arrested him, and imprisoned him in the city of Al-Kaf for nearly 20 years. Then he released him after that, and he continued his journey to Africa in a state of poverty and humiliation, having reached the utmost distress. He arrived in the Tunisian Mahdia in that condition, where he encountered the sedition of Abu Yazid Makhdad ibn Kaydad al-Nukari and his siege of it, and he died there hungry and a stranger. They said: His father Idris ibn Umar ibn Idris II had prayed against him that Allah would make him die hungry and a stranger, and his prayer for him was answered. His death occurred in the year 332 AH.

​Then the Far Maghrib returned to the Idrisids after the emergence of al-Hasan al-Hajjam ibn Muhammad ibn al-Qasim ibn Idris II. After Masalah ibn Habus overthrew Yahya's state, tortured him, and confiscated his wealth and treasures, he appointed Rayhan al-Katami over Fez, then returned to Kairouan. Rayhan remained as governor of Fez and its districts for about three months, when al-Hasan al-Hajjam revolted against him in the year 310 AH and entered Fez among a group of his Shia and supporters. He was a brave and daring man, and he entered it..

​...during a moment of negligence from its people, so he seized it, killed Rayhan (or it is said he exiled him), and the people gathered to pledge allegiance to him. Most Berber tribes in the Maghrib entered his obedience, and he seized a number of its cities, such as Sefrou, Madiyan, the cities of Meknes, and Al-Basra. Authority in the Maghrib was established for him, and he was known as "Al-Hajjam" (The Cupper) because a war broke out between him and his paternal uncle Ahmad ibn al-Qasim ibn Idris II. Al-Hasan attacked his uncle's companions and they were defeated, and three of the rear guard were wounded with cupping lancets (muhajam), so his mentioned uncle said: "My nephew is a cupper (al-hajjam)," and the nickname stuck to him. Regarding this, he said:

​I was called a cupper and I am no cupper ... Rather, due to wounds inflicted by cupping lancets


​Then the tyrant over the Idrisid Ahl al-Bayt, Musa ibn Abi al-Afiya—Masalah's deputy over the governorship of the Maghrib—attacked him. Al-Hasan al-Hajjam went out to meet him, and they met at Fحص al-Zirad near Wadi al-Mutahin between Fez and Taza. Al-Hasan al-Hajjam inflicted a massive defeat on Ibn Abi al-Afiya, the likes of which had not occurred in the Idrisid state, killing about 2,300 of Ibn Abi al-Afiya's soldiers, including his son Minhal, while about 700 of Al-Hasan's soldiers were killed. Then the outcome turned in favor of Musa against Al-Hasan al-Hajjam because Al-Hasan's army returned to Fez routed. When Al-Hasan realized the rout of the army, he hurried and entered Fez alone, leaving his army outside the city. His governor Hamid ibn Hamdan al-Hamdani (or al-Awribi from the villages of Africa) betrayed him, entered upon him at night in his house, bound him, took him, and closed the city gates against the army. Then he sent word to Musa ibn Abi al-Afiya informing him of his action and urging him to advance upon him to secure him, as he was securely bound. Musa ibn Abi al-Afiya rushed to him, entered the Qarawiyyin quarter early in the morning without meeting resistance, and encountered resistance from the Andalusian quarter, fighting it until he seized it. He demanded that Hamid hand over Al-Hasan al-Hajjam to exact revenge for his son Minhal or Sahl. Hamid loathed handing him over due to what he knew of his fate at the hands of his enemy Musa, and began procrastinating because he hated openly shedding the blood of the Ahl al-Bayt. So he came to him at night, released him from his shackles, and lowered him down the city wall without a rope. He fell and broke his shinbone, then took refuge in the Andalusian quarter, where he died in hiding three days after the incident in the year 313 AH. His reign lasted about two years. Then Ibn Abi al-Afiya grew angry with Hamid and wanted to kill him, so Hamid fled and joined the Tunisian Mahdia. Thus, matters were settled for Ibn Abi al-Afiya in the Maghrib, and he annexed all its cities to himself, taking the pledge of allegiance for himself.

​The Story of Musa ibn Abi al-Afiya, Enemy of the Idrisids

​Who is this stubborn tyrant? And the envious foe who met his reward...

​...bringing him to his end as a fugitive and exile from the kingdom of the Maghrib in Wadi Moulouya, after his defection from the noble Ahl al-Bayt. He did not stay after their affliction in the rule of the Maghrib except for 11 years, all of which were warfare against him, until he was killed after his return from the desert in the Moulouya valley as a fugitive, exile, wretched, and humiliated after glory and power. This is Musa ibn Abi al-Afiya ibn Abi al-Dahhak al-Majduli al-Miknasi al-Tsuli.

​Margin Note: "And in the era of this Musa ibn Abi al-Afiya, the Mahdi Ahmad ibn al-Qasim mentioned was besieged, and he had a diviner sister and was buried in Qasr al-Hajar in the year 315 AH."

​In the year 313 AH, his takeover of Fez and taking the pledge of allegiance for himself occurred through the allegiance of tribes and shaykhs. He was not independent by himself; rather, he was a missionary for his masters: Masalah, his benefactor, and Ubaidid-backed Ubaidullah al-Shi'i, Amir of Kairouan and its capital the Tunisian Mahdia, which he named Al-Mahdiyya due to his claim that he was the expected Mahdi. His goal was to unite the Maghrib with Africa because the Maghrib in the era of the Idrisids—the people of Fez—was not subordinate to anyone in the East or West, but rather independent in its authority until the era of Yahya ibn Idris mentioned earlier. Ubaidullah al-Shi'i's commander, Masalah ibn Habus al-Miknasi, followed this to achieve his objective. After the fall of Yahya, power was consolidated for his cousin and left in the hands of Musa ibn Abi al-Afiya. After consolidating his influence, he began purging the Idrisids from the Maghrib, hunting them down, killing them, and expelling them from their homes across all regions of the Maghrib—especially Fez, Salé, Asilah, and Al-Basra. When the noose tightened around them and the army pursued them from behind, killing them, they all took refuge in the fortress of Hajar an-Nasr, which will be discussed later. He descended upon them and besieged them there to eradicate them from the Maghrib. After the siege intensified and matters became so dire that they despaired of life, this occurred in full view of their maternal Berber cousins, who pitied and sympathized with them. Some of them held influence and opinion in the Maghrib's politics regarding Ibn Abi al-Afiya, so they blamed him for his evil deeds and foul intentions toward them, saying to him: "Do you want to cut off the root of the Ahl al-Bayt from the Maghrib and kill them all? This is something we will not agree to nor leave you to do."

​Fearing this, he departed from them to the city of Fez, leaving behind his lieutenant, commander Abu al-Fath al-Tsuli, with a thousand horsemen to prevent them from acting, in the year 317 AH. After the tyrant returned to Fez, he killed its governor over the Andalusian quarter, Abdullah ibn Tha'laba ibn Muharib ibn Abud al-Azdi, appointing his brother Muhammad ibn Tha'laba in his place, then dismissed him and appointed Tuwal ibn Abi Yazid. He remained governor there until Fez slipped from Ibn Abi al-Afiya's hands. Then he moved to Tlemcen and began expelling the remaining Idrisids from its lands, which were under the control of al-Hasan ibn Ahmad Abu al-Aish ibn al-Qasim Kennoun ibn Muhammad ibn al-Qasim ibn Idris al-Taqi. He appointed his son Madin over the Maghrib and settled him in the Qarawiyyin quarter, then...

​...a large army joined him in the lands of Tlemcen, expelling the mentioned Hasan, who took refuge in the city of Melilla from the Moulouya islands. Then Ibn Abi al-Afiya marched to the city of Al-Takour, conquering its kingdom as well, and besieged al-Hasan in his fortress—end of quote from Al-Istiqsa. Ibn Abi Zar' said: "Then he marched to the city of Takrir, known today as Taourirt, and succeeded in conquering it." Al-Istiqsa states: "Then he concluded a peace agreement with al-Hasan regarding his fortress, sent the pledge of allegiance to Abd al-Rahman al-Nasir li-Din Allah the Umayyad in al-Andalus, turned against the Ubaidid call, established his own call, and had the khutbah read for him across all pulpits of the Maghrib in the year 320 AH."

​News of this reached Ubaidullah al-Shi'i in Tunisian Mahdia that he had broken his allegiance and pledged to the Umayyads. Ubaidullah al-Shi'i dispatched his commander Hamid ibn Sahl al-Kitami, along with Hamid ibn Hamdan—who was previously governor of Fez and had fled from Ibn Abi al-Afiya over the matter of handing over al-Hasan al-Hajjam—with 20,000 troops. They met Ibn Abi al-Afiya at a place known as Fahs Maysoun, where a fierce battle took place. Then Hamid attacked him by night, raiding his camp at night, and Ibn Abi al-Afiya and his companions were defeated, fleeing to the city of Tsul (called Ayn Ishaq) where he fortified himself. Hamid ibn Sahl marched to Fez, and when he approached it, its governor Madin ibn Abi al-Afiya fled. Hamid ibn Sahl, commander of Ubaidullah al-Shi'i, entered it and restored its former governor Hamid ibn Hamdan.

​News reached the people of the fortress of Hajar an-Nasr regarding the defeat of Ibn Abi al-Afiya and the flight of his son from the city of Fez. They revolted against Abu al-Fath al-Tsuli, plundered his camp, and broke out of their siege which had lasted four years, in the year 321 AH. During this time, one of Ibn Abi al-Afiya's governors, Ahmad ibn Bakr ibn Abd al-Rahman ibn Sahl al-Judhami, revolted against Hamid ibn Hamdan (governor of Fez on behalf of Ubaidullah al-Shi'i's commander Hamid ibn Sahl), killed him, and sent his head and son to Musa ibn Abi al-Afiya. Then he gave his allegiance to Abd al-Rahman al-Nasir li-Din Allah the Umayyad in the Andalusian quarter of western Europe, and appointed another governor over Fez on behalf of Ibn Abi al-Afiya calling for the Marwanids in the Maghrib. Following the death of Ubaidullah al-Shi'i in the year 322 AH, the call in the Maghrib returned to the Banu Marwan.

​Then, after Ubaidullah al-Shi'i, his son Abu al-Qasim ibn Ubaidullah al-Mahdi succeeded him. When news reached him of what the Maghrib had turned to regarding the Marwanid call, he dispatched his commander Maysur al-Fata—as stated by Ibn Abi Zar', Qadi Ayyad, and Al-Istiqsa—in the year 323 AH, following the death of his father Ubaidullah al-Shi'i. He marched on the city of Fez and besieged it for days until Ahmad ibn Abi Bakr came out to him, pledging allegiance after Ibn Abi al-Afiya had shrunk away...

​...from meeting him, fleeing to take refuge in the city of Al-Kaf. He presented precious gifts and immense wealth before Maysur, who accepted the gifts and wealth. Then he arrested Ahmad ibn Abi Bakr, shackled him, and sent him to Tunisian Mahdia. When the people of Fez were warned of his treachery, they refused him, closed their doors against him, and put forward Hasan ibn al-Qasim al-Luwati. Maysur besieged them for seven months until they consented to peace, making terms that they give him six thousand dinars, pack saddles, felts, water skins, furnishings, and write their pledge of allegiance to Abu al-Qasim al-Mahdi al-Shi'i in Tunisian Mahdia, having the khutbah read for him across all pulpits of Fez. Maysur accepted this from them and departed to continue the war against Musa ibn Abi al-Afiya.

​This was a golden opportunity and a great victory for the oppressed Idrisids over their tyrant and enemy, granted to them by Allah from where they expected it not. Then their sons joined the army of Maysur al-Fata to pursue their enemy Musa ibn Abi al-Afiya. Maysur followed him until he caught up with him, and fierce battles took place between the two parties, mostly fought by the heroic Idrisids. They fought him until he was defeated and fled panting into the desert, where his army dispersed. There he remained in the desert as a fugitive and exile until he returned to the Maghrib alone, defeated, and humiliated, meeting his end in some lands of Moulouya in the year 331 AH (and it is said 341, and it is said 328).

​Thus ended the affair of the tyrant of the Idrisid Ahl al-Bayt after they had endured nearly 20 years of supreme afflictions of killing, torture, exile, displacement, hunger, and bondage. His ultimate intention for total liquidation aimed at complete extermination, were it not for the wise men among his retainers who intervened and stopped him from executing his desire against the noble prophetic Ahl al-Bayt. To them belongs the credit for the survival of this pure and blessed lineage in the Maghrib to this day. Praise be to Allah for His grace and beneficence; to Him belongs every matter, and there is no Lord besides Him.

​Biography of Ubaidullah al-Shi'i

​The historians state: The cradle of the Fatimid state was (the village of Salamiyah) near Homs in what is today known as Syria. The Ubaidids are the Fatimids themselves. Out of fear of the Abbasids, they used to conceal themselves behind covers, hiding like a human hiding behind walls, stones, trees, and clothing. They resorted to this deception so they would not be tracked and their strength undermined, for they used to track the scent of most Alid descendants. For this reason, they would appear at times under this name 


​...and sometimes in its hiding places, so that their true condition becomes confused and the reality of their matter is hidden from them, lest they show great care for them, which would save them from their plotting and targeting them, just as they did with their predecessors. Among them were those killed in battle, those poisoned, and those tortured or imprisoned. All that has been mentioned concerning them can be reviewed by whoever wishes to return to it.

​The lineage of Ubaidullah al-Shi'i goes back to the lineage of Maymun al-Qaddah from the Daysanites, the Daysaniyyah, and the Batiniyyah. They were the handiwork of the people of the Alid House, who did this so they could reach out to prominence through the missionary preachers of their Shia without their paternal uncles, the Abbasids, noticing them. They moved to the village of Salamiyah from Basra, and Ubaidullah al-Shi'i—known as the head of the Fatimid-Ubaidid State—is from the lineage of Maymun al-Qaddah. His true name is (Saeed ibn al-Hussein) ibn Abdullah ibn Maymun al-Qaddah, and it has been said that Ubaidullah came to Egypt for the aforementioned political purpose. The titles, no matter how secretive they were and how doubts and suspicions hovered around them, cast the truth into darkness until its reality could not be distinguished. Consequently, from this doctrine, two main branches (tutān kubrīnān) emerged:

  1. ​One of them is a moderate, organized movement whose center is the village of Salamiyah. It is the cradle of the Fatimid-Ubaidid state, the collection point of its secrets, similar to what the Al-Humaymah movement was during the days of the Abbasid mission.

  1. ​The other is a deviant power characterized by anarchy, deviation, and straying from the path. Its first appearance was in Iraq, and the portents of its evil appeared during the reign of Al-Mu'tamid at the hands of the Qarmatians of the Alids. Look at history regarding the Batinis, their actions, conditions, and how the Alids and their Shia, with the passage of time, struck at the Abbasid state from its very foundations until its status weakened.

​Ubaidullah al-Shi'i was one of the astute political tacticians, and there is a lengthy dispute regarding his lineage. Some of what has been mentioned previously has been stated, and Ali al-Rida, the leader of the Alids in Baghdad, said regarding them: "They are from us". Some of his poetry indicates that they claim kinship with them, except that politics—which prevented them from their true garb—made this the case. He had dispatched men from his Shia in the Maghrib preaching the imminent appearance of the Expected Mahdi, and they called to him. Many people responded to them, and when news of them reached the Abbasid Caliph Al-Muktafi, who opposed their mission, he fled in disguise until he reached Sijilmasa. He had him arrested, along with his son Al-Qasim. When the affair of Ubaidullah al-Shi'i intensified in Africa, he came to Sijilmasa, released them from prison, and then they returned to Africa. He was pledged allegiance to in Kairouan with the Public Pledge of Allegiance in the year 297 AH, and his rule became established and he sent workers to the surrounding areas, and he founded the city of Mahdia in Africa (Tunisia), and made it the base of his kingdom and capital in the year 308 AH. He finished building it in the year 303 AH (Note: as written in the text), and his days lasted about 24 lunar years.

End of the Section, to be continued 

Author 

Taher Ben Abdessalam El Lhioui Al-Wahhabi Al-Alami Al-Hassani
Foreword
Abdallah Guennoun
Digital Edition, Translation and Presentation
Jaafar El Lhioui
Northern Morocco Archive 

 Conclusion
The archival lineage records preserved by historian Taher El Lhioui offer critical insights into the structural dynamics of the early prophetic households. By documenting these primary transmissions and clarifying descendant pathways, his work serves as an essential bridge connecting foundational Islamic history with the genealogical heritage of Northern Morocco. 
Stay tuned for the upcoming chapters of this digital series as we continue to unlock rare documents from the Northern Morocco Archive.


​



Jaafar El Lhioui
Researcher, Editor, and Digital Activist
El lhioui jaafar
By : El lhioui jaafar
باحث مستقل، شغوف بالتنقيب عن الحقيقة التاريخية، مؤمن بأن الأرشيف هو ذاكرة الأمم، وأن قراءة الماضي بعينٍ نقدية هي السبيل إلى فهم الحاضر
تعليقات