The Hammadid–Zirid War was the first in a series of conflicts between Hammadid and Zirid forces. It lasted from Hammad's removal of allegiance to the Fatimid Caliph and his submission to the Abbasids in 1014 until the recognition of Hammadid independence with the treaty between the two dynasties in early 1018.[1][2][3] The war was primarily driven by Zirid EmirBadis's attempts to assert his authority over Hammad's domains, while Hammad sought to keep Zirid rule and authority out of Central Maghreb.[1][4]
Hammad, a long-serving lieutenant of the Zirid emirs, had successfully divided the Zenata tribes and prevented them from establishing a foothold in Central Maghreb.[5][6] For his victorious campaigns in the west, Hammad was granted overlordship over the city of Achir as well as the Central Maghreb and was permitted to build a fortified city that would serve as his base of operations.[6][7] However, this greatly elevated his status, igniting feelings of envy and jealousy among his enemies, who began to slander him and incite Badis against him.[1][8]
Background
The final break between Hammad and his nephew Badis occurred around 405/1014.[8] When Badis' son al-Mansur was declared heir to the Zirid throne, Badis attempted to carve a small principality out of Hammad's territory for the new crown prince. He demanded that Hammad relinquish control of the districts of Constantine, Tījis, as well as Qasr al Ifriqi.[1][9] Hammad refused, and soon after, he removed the name of the Fatimid caliph from the khutba, replacing it with that of the SunniAbbasid caliph in Baghdad.[10][6]
He then proceeded to massacre the Shi'a in his domains.[4][7] By changing the state creed so abruptly and violently, Hammad was proclaiming his complete independence from the Zirid court.[11][2]
Badis could not let such a challenge go unpunished and personally led an expedition to chastise his uncle.[9]
Badis consulted Ibrahim ibn Buluggin, who on the same occasion was the brother of Hammad,[1] on who should deliver the letter to Hammad. Ibrahim eagerly volunteered, saying, 'Our master will not find a servant among his servants more committed to his service than me.'[12][13]
He pledged that his journey would not take more than twenty days.[2] Badis, on the advice of someone close to him, was advised to detain Ibrahim, preventing him from traveling until Hammad's obedience and promptness to his orders could be confirmed.[12] But ultimately, he said to Ibrahim, 'Go to your brother Hammad. If you are truthful in what you said and fulfill your promises, then proceed. Otherwise, do what you intend.'[13][2] Ibrahim left with Hashim bin Jaafar on 11 April 1015 AD, accompanied by 400,000 dinars in gold and all his treasures, men, and slaves.[12][1] Badis did not obstruct him, otherwise, his departure with all his wealth and men would have indicated otherwise. Hashim ibn Jaafar sensed that Ibrahim might betray him when they got closer to his brother. Shortly after, Ibrahim excused himself to attend to an urgent matter in Béja, promising to catch up quickly.[2][13]
As soon as Ibrahim reached Tamdit, which is a two-day journey from Laribus, he wrote to Hammad to inform him of his plans.[1][2] Hammad arrived with an entourage of thirty thousand horsemen.[13] They united their forces and renounced their allegiance.[8][14]
When Hammad reached Béja on his way to meet Badis, the people of the city sought his protection, and he assured them of their safety. However, once he entered the city, he started killing, looting, and taking their wealth.[14][1] This served as a lesson for all cities and created a significant obstacle for Hammad due to his own policies.[8] In contrast, Badis remained faithful to those who trusted and allied with him. As a result, many of Hammad's supporters, including Zenata and Sanhadja tribes, abandoned him.[2][4] When Hammad reached Achir, his city where his subject Khalaf al-Himyari resided, Khalaf prevented him from entering and declared his allegiance to Badis, further demonstrating the impact of their differing policies.[1][8] This left Hammad in a difficult position as he hoped to fortify himself in the city.[3][14]
All these circumstances set the stage for the outcome of the battle between Badis and Hammad.[8] When Badis crossed the Chelif River after seizing the city of Achir at the beginning of Jumada al-Awwal 406 AH (1015 AD) and confronted Hammad,[1][12] Badis's men were determined to either endure or die, knowing Hammad's cruelty towards captives.[14] Hammad was utterly defeated, and his army was plundered.[15][3]
If Badis's troops had not been preoccupied with looting, Hammad himself would not have escaped.[8][13] The spoils and wealth taken were beyond measure. Hammad then proceeded to fortify himself at the fortress of Timici before joining his brother five days after at Qal'at Bani Hammad.[1] Upon reaching their fort, Ibrahim informed his brother of the lack of supplies in case of a long siege by Badis. They then proceeded to sack the city of Dkama not far from M'sila.[3][2] The city had already submitted to Badis, which angered Hammad. He ultimately killed three hundred men, took all their supplies, and returned to his fortress.[14][1]
Meanwhile, Badis continued eastward and arrived in M'Sila on 13 November 1015 AD.[1][12] He received an envoy from his uncle Ibrahim, delivering apologies and reminding Badis of Hammad's past services.[1] Badis likely set conditions deemed unfair, such as unconditional surrender.[2] He left his army encircling the fortress and distributed money among his soldiers to incite enemy desertions.[8][14] This strategy caused part of Hammad's army to desert and led to a shortage of supplies and rising prices within the besieged fortress.[2] It seemed that Hammad was on the verge of defeat, and his dynasty appeared to be on the brink of extinction.[9][8] Unfortunately for the Zirids, Badis died unexpectedly in 407 AH/1016, and he was succeeded by his eight-year-old son al-Mu'izz since al-Manşūr had passed away before his father.[5][6] The Zirid army withdrew to Qayrawan, allowing Hammad to reclaim his lost territories.[9][3] The following year, Hammad sent his son al-Qa'id to the Zirid court with gifts, and a treaty was signed maintaining the status quo. The Zirids were now willing to acknowledge an independent Hammadid state in the Central Maghrib, their ancestral homeland.[9][4]
Hammadid–Zirid treaty
Nearly a year had elapsed since Hammad's conflict with Kurama, al-Muizz's uncle, in Achir.[2] Taking advantage of every fleeting opportunity, Hammad managed to defeat Kurama, partly due to the plundering of Kurama's treasury by his own men.[1][14] Despite Kurama's advantage of seven thousand men compared to Hammad's fifteen hundred, and the fact that all the people of Achir were against him, Hammad was victorious.[8][4] During this period, al-Muizz mobilized to confront Hammad on July 31, 1017.[2] At that time, Hammad was besieging Bagai after capturing M'sila and Achir. Al-Muizz's advance forced Hammad to withdraw from Bagai. They engaged in battle at the end of Rabi' al-Awwal, which corresponds to the 26th of August 1017.[2][14] Within a few hours, Hammad and his forces were decisively defeated. Al-Muizz's troops overwhelmed them, capturing their equipment, wealth, and other possessions. Ibrahim, Hammad's brother,[12][3] was taken prisoner, while Hammad, though injured, managed to escape, and his followers scattered.[8][1]
Back at his fortress, Hammad sent an envoy to al-Muizz seeking forgiveness and proposing reconciliation.[4][2] Al-Muizz responded, "If you are sincere, send your son al-Qa'id to us."[1] Hammad replied that he would send al-Qa'id or come himself if he received a letter from his brother Ibrahim confirming al-Muizz's assurances.[12] Ibrahim arrived, secured the promises from al-Muizz, and informed Hammad, expressing gratitude for al-Muizz's kindness.[2][14]Historian Abdelhalim Oweis notes that several factors likely influenced al-Muizz's acceptance of Hammad's offer. The young age of the Emir, who had not yet turned nine, and concerns among the Emir and his advisors about facing a potentially greater threat than Hammad likely played roles.[8][15]
Despite these factors, al-Muizz reached an agreement with Hammad's son, al-Qa'id.[8] Under the terms, Hammad was granted control over M’sila, Tobna, Zab, Achir, Tahert, and any newly conquered lands in the Maghreb.[2][1] Al-Muizz also appointed al-Qa'id to oversee Tobna, Mars al-Dejaj, the lands of the Zouaoua, Magra, Dekma, Belezma, and Souk Hamza.[12][3] The agreement was not simply about dividing the Central Maghreb between the father and his son. Instead, it acknowledged Hammad as an independent ruler over M’sila, Tobna, the Zab, Achir, and Tahert, as well as any additional regions he might conquer in the Central Maghreb.[1][3] It was anticipated that al-Qa'id would succeed his father.[2] Thus, the Hammadid–Zirid agreement established Hammad as an independent emir in the Central Maghreb, leading to a division of the Sanhadja tribe into two states: the Zirid state in Ifriqiya and the Hammadid state in the Central Maghreb.[1][15][2]