Draft:Hammadid-Zirid War (1014-1016)

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 1017. The war was primarily driven by Zirid Emir Badis's attempts to assert his authority over Hammad's domains, while Hammad sought to keep Zirid rule and authority out of Central Maghreb.

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. 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. 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.

Background
The final break between Hammad and his nephew Badis occurred around 405/1014. 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. Hammad refused, and soon after, he removed the name of the Fatimid caliph from the khutba, replacing it with that of the Sunni Abbasid caliph in Baghdad. He then proceeded to massacre the Shi'a in his domains. By changing the state creed so abruptly and violently, Hammad was proclaiming his complete independence from the Zirid court. Badis could not let such a challenge go unpunished and personally led an expedition to chastise his uncle.

Badis consulted Ibrahim ibn Buluggin, who on the same occasion was the brother of Hammad, 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.' He pledged that his journey would not take more than twenty days. Badis, on the advice of someone close to him, decided to detain Ibrahim, preventing him from traveling until Hammad's obedience and promptness to his orders could be confirmed. 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.' 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. 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.

As soon as Ibrahim reached Tamdit, which is a two-day journey from Laribus, he wrote to Hammad to inform him of his plans. Hammad arrived with an entourage of thirty thousand horsemen. They united their forces and renounced their allegiance. 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. This served as a lesson for all cities and created a significant obstacle for Hammad due to his own policies. 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. 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. This left Hammad in a difficult position as he hoped to fortify himself in the city.

Aftermath
All these circumstances set the stage for the outcome of the battle between Badis and Hammad. 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, Badis's men were determined to either endure or die, knowing Hammad's cruelty towards captives. Hammad was utterly defeated, and his army was plundered. If Badis's troops had not been preoccupied with looting, Hammad himself would not have escaped. 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. 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. 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.

Meanwhile, Badis continued eastward and arrived in M'Sila on 13 November 1015 AD. He received an envoy from his uncle Ibrahim, delivering apologies and reminding Badis of Hammad’s past services. Badis likely set conditions deemed unfair, such as unconditional surrender. He left his army encircling the fortress and distributed money among his soldiers to incite enemy desertions. This strategy caused part of Hammad’s army to desert and led to a shortage of supplies and rising prices within the besieged fortress. It seemed that Hammad was on the verge of defeat, and his dynasty appeared to be on the brink of extinction. 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. The Zirid army withdrew to Qayrawan, allowing Hammad to reclaim his lost territories. 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.