Abbasid civil war (865–866)

The Abbasid civil war of 865–866, sometimes known as the Fifth Fitna, was an armed conflict during the "Anarchy at Samarra" between the rival caliphs al-Musta'in and al-Mu'tazz, fought to determine who would gain control over the Abbasid Caliphate. The war, which lasted for about a year, largely revolved around a prolonged siege of Baghdad and ended with al-Mu'tazz as sole caliph. Al-Musta'in was abandoned by his supporters and forced to abdicate; in spite of a guarantee that his life would be spared, he was executed shortly afterward.

The outcome of the war was a major victory for the Turkish military establishment, which had been responsible for al-Mu'tazz's rise to power, and allowed the Turks to maintain their effective power over the government and military of the caliphate. The partisans of al-Musta'in, namely the Tahirid family, the Arab military factions, and the citizens of Baghdad, continued to be excluded from the politics of the central government after their surrender, although they were allowed to keep the positions they had before the war. Central Iraq, where most of the fighting took place, was devastated by the activities of both sides.

The historian al-Tabari provided a lengthy and detailed account of the war. Other Muslim historians, such as al-Mas'udi and al-Ya'qubi, also mentioned the war in their works.

Background
The caliph al-Mutawakkil (847-861) had created a plan of succession that would allow his sons to inherit the caliphate after his death; he would be succeeded first by his eldest son, al-Muntasir, then by al-Mu'tazz and third by al-Mu'ayyad. In 861 al-Mutawakkil was assassinated by a group of Turkish military officers, likely with the support of al-Muntasir. During al-Muntasir's short reign (861-862), the Turks pressured him into removing al-Mu'tazz and al-Mu'ayyad from the succession. When al-Muntasir died, the Turkish officers gathered together and decided to install the dead caliph's cousin al-Musta'in on the throne. The new caliph was almost immediately faced with a large riot in Samarra in support of the disenfranchised al-Mu'tazz; the rioters were put down by the military but casualties on both sides were heavy. Al-Musta'in, worried that al-Mu'tazz or al-Mua'yyad could press their claims to the caliphate, first attempted to buy them off and then threw them in prison.

After the suppression of al-Mu'tazz's supporters, the caliph's reign continued largely unabated until 865. The continual inability of the government to pay the soldiers, however, combined with infighting among the ranks of the Turks, threatened the stability of the regime. At the beginning of 865, a quarrel among the Turkish officers broke out, and the general soldiery quickly became involved. When one of the officers was killed, the soldiers turned violent, and soon they were rioting throughout the streets of Samarra. Faced with this hostile situation, al-Musta'in and two of the senior Turkish officers, Wasif and Bugha al-Sharabi, decided to leave Samarra for Baghdad, where they were arrived in the first week of February 865. Upon their arrival, they were greeted by the city's powerful Tahirid governor, Muhammad b. 'Abdallah, in whose palace the caliph took up his residence.

When the Turks in Samarra realized that al-Musta'in had departed from the city, they cut off traffic to Baghdad. A delegation of Turks then went to see the caliph; when they arrived, they asked for forgiveness for their actions and for the caliph to return with them to Samarra. Al-Musta'in, while promising the Turks that they would continue to be paid, refused to leave Baghdad, and he and Muhammad b. 'Abdallah mocked them for their perceived insolence. The humiliated Turks angrily returned to Samarra and told their compatriots what had happened; they then decided to depose al-Musta'in. The soldiers released al-Mu'tazz from his prison and acknowledged him as their caliph. Al-Mu'tazz agreed to the proposal and an oath of allegiance was drawn up; many of the officials in Samarra then swore allegiance to him.

Beginning of hostilities
With two members of the Abbasid family now claiming to be caliph, war became inevitable. On al-Musta'in's side, Muhammad b. 'Abdallah quickly took command of the military effort. He ordered that all food shipments from Baghdad to Samarra be halted, and instructed allies in the Mosul region to do the same. Letters were sent by Muhammad to friendly commanders calling on them to mobilize their forces, and a recruitment drive was initiated in Baghdad. In preparation for a siege, the city was fortified, with the work being completed by February 22. The bridges and canals around al-Anbar were destroyed, flooding the area and hindering any possible enemy troop movements there. Muhammad also wrote to the tax officials throughout the empire, instructing them that their revenues were to be sent to Baghdad instead of Samarra.

For his part, al-Mu'tazz wrote to Muhammad, urging him to declare allegiance to him. Soon after, al-Mu'tazz put his brother Abu Ahmad (the later al-Muwaffaq) in command of an army and instructed him to fight against al-Musta'in and Muhammad. The army, consisting of five thousand Turkish and Ferghanan (Faraghinah) soldiers under the leadership of Kalbatikin al-Turki and two thousand North African (Magharibah) soldiers under the leadership of Muhammad b. Rashid al-Maghribi, departed Samarra on February 24. Six days later they arrived in Ukbara, where Abu Ahmad led the prayers in the name of al-Mu'tazz. The Turks and North Africans began looting the area between Ubkara and Baghdad, causing many of the local residents to abandon their estates and fields. On March 10, Abu Ahmad and his army appeared before the Shammasiyah gate on the East side of Baghdad, and the siege of the city began.

Al-Musta'in
Neither caliph participated in the direct military operations of the war. In Al-Musta'in's case, he was generally content to leave the responsibility of conducting the war effort to Muhammad b. 'Abdallah. As commander, Muhammad opted for an overall defensive strategy. Relying on his position in Baghdad, he was reluctant to engage in any sort of offensive operations outside the city and its surrounding districts, even when he was advised by others to do so. While he did make an effort to securing the nearby towns that controlled access to the city, there is no mention of any attempt to attack Samarra. By staying within Baghdad and keeping the city's supply routes open, while at the same time cutting off foodstuffs and tax receipts meant for Samarra, Muhammad likely believed that he could outlast al-Mu'tazz's armies.

A massive amount of work was done to prepare Baghdad for a siege. Walls and trenches were constructed on both the east and west sides of the city, at a cost of over three hundred thousand dinars. Ballistas and mangonels were installed on the walls, and "war engines" designed to hinder enemy movement were placed in front of the city gates. The market awnings were removed so as to prevent them from being set on fire, and the areas outside the city were ploughed so that the mud would entrap the attackers. A few days after the fighting began, Muhammad ordered the razing of a large area behind the walls, so that the defenders would have more room to operate in.

Muhammad had numerous sources of manpower in his allies and in the people of Baghdad. He could rely on many friendly military commanders to heed his call for assistance, and in the early months of the war several small regiments from Iraq, the Jazira, the Jibal, the Arab-Byzantine frontier and elsewhere arrived in Baghdad. Muhammad also had an ally in his nephew Muhammad b. Tahir, who was the governor of most of the eastern provinces, although at the time the latter was largely preoccupied with the rebellion of Hasan b. Zayd in Tabaristan. In order to augment the ranks of his soldiers, Muhammad instituted a draft in Baghdad and called on for volunteers to serve al-Musta'in. A group of Khorasani pilgrims en route to Mecca at the time the war began were asked to stay and fight. Many of the city's brigands were also recruited and provided with weapons. At first they were given mats to protect themselves and bags of rocks or bricks to attack the enemy with; later they were given clubs, placed under their own chief and registered in the military roll so that they could be paid. Arab Bedouins and Kurdish tribesmen from the surrounding regions also fought for al-Musta'in.

In keeping with normal Abbasid court practice, gifts were routinely bestowed upon officers and soldiers by both al-Musta'in and Muhammad. Tabari's narrative of events contains numerous instances of commanders being rewarded for their service. They were given gifts on a number of occasions, such as their initial arrival in Baghdad with their troops, distinguishing themselves on the battlefield, or being selected to lead an important mission. Traditional robes of honor were regularly given out; other gifts included jewelry, ceremonial swords, money, and increased allotments for the troops.

The exact size of the army under Muhammad's command is not explicitly stated, but it was likely much greater than al-Mu'tazz's forces. As many of his units were irregulars, however, their conduct in battle was not always reliable, and they were disciplined often for their failure to follow orders. In addition, while many army commanders were willing to pledge themselves to al-Musta'in's cause, not all of them were willing to take orders from Muhammad; there are multiple instances of pro-Musta'in regiments outside Baghdad acting independently and engaging the Turks on their own initiative.

Al-Mu'tazz
From the start of the crisis, al-Mu'tazz was concerned with portraying himself as the legitimate caliph. He had been proclaimed as heir-apparent during his father's lifetime, and according to the succession arrangements he should have become caliph after the death of al-Muntasir. When he had signed away his rights to the caliphate in 862, he had been under duress to do so, with the Turks threatening to kill him if he refused, and therefore he considered the deed of abdication to be void. He also sought to convince the people that they could switch their allegiance to him without breaking the oath they had taken to serve al-Musta'in, and went through the effort to explain in detail how this could be done in a letter to Muhammad b. 'Abdallah.

Al-Mu'tazz was initially accommodating toward those in Samarra who opposed his bid for the caliphate, and did not compel anyone to swear the oath to him if they refused to do so. He did, however, write to commanders stationed throughout the empire requesting their support, and soon reinforcements were arriving in Samarra. As the conflict progressed, he steadily gained followers as members of al-Musta'in's camp began to defect to him. He also made efforts to entice al-Musta'in's officers, writing offers to them and promising substantial rewards if they would switch their allegiance to him.

Al-Mu'tazz's brother Abu Ahmad was put in charge of the Samarran forces at the beginning of the war. He was charged by the caliph with defeating al-Musta'in and Muhammad b. 'Abdallah, and was given the authority to command the army in any manner he pleased. Abu Ahmad's overall strategy was to keep Baghdad under constant attack from his troops, and to gain the surrender of the city by either assaulting it or starving its inhabitants until they lost the will to fight any longer. Toward this end, al-Mu'tazz sent armies to secure the neighboring towns that controlled access to Baghdad, and Abu Ahmad attempted to halt and seize any revenue shipments heading toward the city. The way in which Abu Ahmad ran the siege was not unquestionably accepted by al-Mu'tazz, who reportedly wrote him a letter in the middle of the war complaining of his lack of progress in forcing al-Musta'in's capitulation, but he remained in command of the main besieging force throughout the entire conflict.

Abu Ahmad's army at the beginning of the siege numbered approximately 7,000 soldiers. Additional troops sent from Samarra a short time later increased its size to 11,000, though a large number of the reinforcements were killed soon after their arrival. At a later point in the war, a spy for Muhammad b. 'Abdallah reported that the besieging armies on the East and West sides of Baghdad totaled 19,000 men, and that al-Mu'tazz had very few additional troops to put in the field, since Samarra had been almost completely emptied of soldiers.

Major events of the war
Fighting during the war lasted for slightly less than a year, with hostile engagements occurring everywhere from the Jazira in the north to the borders of Khuzestan in the southeast. Most of the battles of the war, however, took place in Iraq; specifically at Baghdad, where al-Musta'in had made his residence, and the districts surrounding the city.

Baghdad
For the first few days after the arrival of Abu Ahmad and his army before the gates of Baghdad, the two sides refrained from directly engaging each other in combat. On March 14, Muhammad b. 'Abdallah approached the enemy camp and called on the Samarrans to depart; if they did, he guaranteed that al-Musta'in would recognize al-Mu'tazz as heir-apparent. If they refused to leave, however, Muhammad intended to initiate hostilities the following morning.

The next day, the Samarrans approached the Shammasiyyah and Khorasan gates along the eastern wall and attempted to force their way through them. The Baghdadis responded by firing upon them with arrows, mangonels and ballistas, inflicting heavy casualties upon the attackers. At the Khorasan Gate, the Turks attempted to move up an artillery piece into firing range, but a charge by the regular and irregular Baghdadi forces dislodged the enemy from their position. By the end of the day, the Samarrans withdrew back to their camp; both sides had sustained hundreds of casualties from the fighting.

On March 20 a second army sent from Samarra, consisting of 4,000 Turks, North Africans and Ferghanans, arrived in front of the western side of Baghdad and made camp near the Gates of the Fief and Qatrabbul. The next morning, Muhammad b. 'Abdallah ordered a large contingent of infantry and cavalry to battle them. At first the Samarrans had the upper hand, and were able to force the Baghdadis into a narrow area near the Gate of the Fief. Baghdadi reinforcements soon arrived, however, and the combined forces were able to drive the Samarrans back. Having gained the initiative, the defenders charged and forced the Samarrans to retreat to an area where yet another Baghdadi force lay in ambush. At this point, the Samarran retreat turned into a rout, and the troops began to flee for their lives. Many attempted to swim across the Tigris to Abu Ahmad's camp, but were seized by boats patrolling the river. The rest turned north, with some of the soldiers going all the way back to Samarra.

The battle for the Qatrabbul Gate had been a massive victory for the Baghdadis. Of the four thousand Samarrans stationed on the western side of the city, two thousand of them had been killed, with several of their heads being hung around Baghdad, and many others were taken prisoner. In Samarra, news of the defeat was met with rioting; many among the populace apparently considered the battle to be a sign of the weakness of al-Mu'tazz's forces. Muhammad b. 'Abdallah, however, refused to follow up on his victory. Rejecting the council of his advisors to press his advantage and pursue the fleeing soldiers, his only order after the battle was to have proclamation of victory drawn up and read in the Jama Mosque of the Round City. Meanwhile, Abu Ahmad's army, which is not mentioned as having participated in the battle that day, remained encamped on the eastern side. As a result, the siege of the city continued.

After the battle for the Qatrabbul Gate, the siege effectively turned into a stalemate. Throughout the late spring and summer, the Samarrans and Baghdadis regularly engaged each other around the defensive fortifications of the city and inflicted many casualties on each other, but neither side was able to gain a clear advantage. Over the following months, the fighting spread to the districts neighboring Baghdad, as both sides fought to control the routes leading into the city. The Samarrans were able to limit the level of supplies reaching the defenders, but were unable to prevent the Baghdadi armies from moving in and out of the city.

The stalemate around Baghdad remained unbroken until early September. On the morning of September 8, however, the Samarran armies on both sides of the city engaged in a major assault on the fortifications. While the Samarrans on the eastern side attacked the Shammasiyyah Gate, the Turks and North Africans on the western side managed to punch through the initial line of defenses and advance to the Anbar Gate. Despite being caught unaware, the defenders at the Anbar Gate put up a staunch resistance, but eventually they were forced to retreat and the Anbar Gate was set on fire. The Samarrans then entered Baghdad and spread throughout the Harbiyah quarter of the city, setting fire to the areas that they entered. The residents of the neighborhoods that the Samarrans passed through fled for their lives, and the Samarran troops planted flags in the parts of the city that they conquered.

In response to the assault Muhammad b. 'Abdallah gathered his commanders together, and then sent men to the gates all along the western side of the city. The reinforcements engaged the Samarrans and, after killing a large number of them, forced them back to the gateways. Fighting continued until the late afternoon, with the defenders finally managing to expel the Samarrans from the gates and forcing them to flee back to their camp. The areas in the wall where the Samarrans had broken through were ordered repaired. The assault on the eastern side of the city also failed, as the Baghdadis were able to force the attackers back. As with the fighting on the western side, many Baghdadi and Samarran soldiers were killed in the battle for the Shammasiyyah Gate. The assault having therefore failed, the Samarrans returned to their siege positions.

As the siege continued into autumn, Muhammad worked with his lieutenants to plan a sally in an attempt to break the stalemate. The mangonels and ballistas along the walls were prepared for action, and in late November the city gates were opened. The entire Baghdadi army then came out of the city, while river boats loaded with bowmen and artillery moved up the Tigris. They attacked the Samarran army and routed them, forcing them to flee. The Samarran camp was plundered and the irregulars began cutting off the heads of the slain. The Samarran position was saved only when Abu Ahmad made a stand and rallied the troops to regroup; at the same time, the Baghdadis lost their focus and their charge stalled. The Samarrans soon returned to their camp, while the Baghdadis retreated back to the city.

Al-Nahrawan
The town of al-Nahrawan lay just to the east of Baghdad. Its importance lay in the fact that it was the first stage on the road from Baghdad to Khorasan, the latter of which was governed by Muhammad b. 'Abdallah's nephew; whoever controlled the town would therefore be able to stop or allow transportation between the two locations.

Before the siege of Baghdad began, Muhammad b. 'Abdallah sent five hundred infantry and cavalry to al-Nahrawan to defend it against the Turks. Later, another seven hundred soldiers were dispatched to the town to reinforce the first group. On March 19, nine days after Abu Ahmad had arrived in front of Baghdad, a force of Turks marched to al-Nahrawan challenge Muhammad's control of it. The defenders decided to meet the Turks on the field, and a battle ensued. The Turks soon gained the upper hand, and the defenders turned and fled to Baghdad. Fifty of the defenders had died in the battle, and the Turks sent their heads to Samarra, along with mounts and weapons that the defenders had abandoned. With the Turks victorious, they gained control of the Khorasan road, and traffic between there and Baghdad was cut off. When Muhammad learned of the defeat, he recalled troops stationed further down the road at Hamadan and ordered their return to Baghdad.

Although Muhammad is not recorded as having made any attempts to retake al-Nahrawan, the town continued to suffer during the conflict. At some date after the battle, a group of Samarrans returning from deployment in the Jibal entered al-Nahrawan. For unstated reasons, the Samarran commander ordered his troops to plunder the town. The soldiers then began attacking the local residents, and most of the citizens were forced to flee.

Al-Anbar and Qasr ibn Hubayrah
Al-Anbar, lying on the Euphrates to the west of Baghdad, was a major town in the early Abbasid era. At the outbreak of hostilities, Muhammad b. 'Abdallah ordered its ruler to prepare for its defense. The canals and bridges around the town were cut, and the surrounding area was turned into a large swamp. By the middle of spring the commander of al-Anbar had raised a force of several thousand Bedouin recruits, and he sent a request to Muhammad for reinforcements. Muhammad promptly ordered over a thousand more cavalry and infantry to depart for the town.

In Samarra, meanwhile, plans were developed to attack al-Anbar, and soon al-Mu'tazz sent a force of Turks and North Africans to take the town. The defense at al-Anbar was split into two groups, with the reinforcements stationed outside the town and the Bedouins within. When the Samarran army arrived before al-Anbar, they caught the reinforcements by surprise and quickly fell upon them. Some of the defenders put up a fight, but they soon fled, with many of them killed or becoming prisoners. When the commander of the town saw the reinforcements flee, he decided to abandon his post. He and his troops crossed over to the other side of the river, cut the pontoon bridge, and made their way back to Baghdad.

With al-Anbar now lacking any defense, its residents decided to surrender on terms. After giving guarantees of safe conduct to the Anbaris, the Turks and North Africans entered the town, and allowed the people to go about their business. The next day, however, the soldiers seized a shipment of goods arriving from Raqqa and began looting the town. They sent the heads of the slain to Samarra, along with the prisoners that had been captured, and unsuccessfully attempted to dam a water route running between the Euphrates and Baghdad.

When the defeated armies of al-Anbar arrived at Baghdad, Muhammad gave orders that the town was to be retaken. A contingent of troops was sent to Qasr ibn Hubayrah further down the Euphrates and awaited orders to advance. Meanwhile, an army of over a thousand men was raised in Baghdad and put under the command of al-Husayn b. Isma'il, who was instructed to head directly to the town and defeat the Samarran garrison stationed there. After a delay caused by an issue with the troops' pay, the army departed in late June.

The Baghdadi army was assailed almost immediately after their departure by the Turks and North Africans, who attempted to prevent their reaching al-Anbar. In spite of stiff resistance, the Baghdadis were able to construct a bridge across a canal guarded by the Turks and fight them off, but after twelve days they had still failed to reach al-Anbar. Eventually the Turks, who had spies in the al-Husayn's army, were able to ambush their camp. Despite inflicting heavy casualties on the attackers, the Baghdadi army soon fell in disorder, and many of the soldiers were either killed or drowned in the Euphrates. The cavalry turned tail and fled, and when the officers realized that they had lost control of the situation they retreated as well. The Turks then plundered the enemy camp and rounded up the prisoners they had captured. Both sides suffered hundreds of dead and wounded from the fighting.

The remnants of the defeated army retreated back to Baghdad, encamping in the city suburbs in the first week of July. Muhammad gave orders that al-Husayn was to be refused entry to Baghdad, and that any of al-Husayn's men that did not promptly leave the city for his camp would be flogged and denied pay. Al-Musta'in also sent a letter to the encamped soldiers, chastising them for their failure and accusing them of disobedience and mutiny. Al-Husayn was told to gather his men and make another effort to retake al-Anbar. By mid-July, al-Husayn's forces were ready, and for the second time they headed to retake the town.

Al-Husayn's second campaign was to end as badly as the first. Once again the Turks defending the land between Baghdad and al-Anbar attacked the Baghdadi army. Al-Husayn was able to fight them off for several days, but eventually the Turks were able to outmaneuver him and rout the guards stationed on his flanks. When they attacked al-Husayn's army itself, they quickly defeated his men and overran his camp. Al-Husayn himself managed to escape on a river skiff, but a hundred of his men were killed and 170 had been taken prisoner, including several of the officers. Al-Husayn and the other survivors returned to Baghdad, and there were no further attempts to retake al-Anbar.

Qasr ibn Hubayrah, the other western town garrisoned by Muhammad's forces, was taken by the Turks shortly after. Following the conquest of al-Anbar, the Samarran army headed to Qasr ibn Hubayrah and intended to expel the Baghdadis stationed there. Instead, its commander decided to flee the town, giving it up to the Turks without resisting.

Al-Mada'in
Al-Mada'in, to the south of Baghdad in the direction of Wasit, was a series of settlements lying in the midst of the ancient Persian imperial centers of Ctesiphon and Seleucia. On April 21, on the orders of Muhammad b. 'Abdallah, Abu 'l-Saj Dewdad departed Baghdad for al-Mada'in at the head of three thousand cavalry and infantry units. He arrived in the area and settled his troops there. Later he wrote to Muhammad requesting reinforcements, which were sent to him.

Over the course of the summer, the Turks began appearing in the vicinity of al-Mada'in in strength. Abu 'l-Saj responding by advancing further south, to the district of Jarjaraya, where in August he defeated a contingent of Turks and killed their commander. In October he again fought the Turks near Jarjaraya and killed or captured a large number of them. Despite these victories, Abu 'l-Saj was reportedly unsatisfied with the performance of his troops during the fighting, and Muhammad arranged for more reinforcements to be sent to assist him. The reinforcements set out on October 23 and, after marching the entire day, arrived at al-Mada'in just as an army of Turks also appeared before the city.

Combat between the two sides began, but the defenders were quickly overwhelmed when the Turks found a breach in the city wall and forced their way through it. The defenders tried to implement an orderly retreat, with the infantry being loaded onto boats and moved along the river while the cavalry covered their withdrawal, but the Turks continued to engage them and the commander of the reinforcements died in the chaos. With al-Mada'in now lost to them, the survivors made their way to Abu 'l-Saj's camp. Muhammad was angered by the result of the battle, and ordered several of those who had fought at al-Mada'in to be placed under house arrest.

End of the war
As the siege of Baghdad wore on, it began to have its intended effect. Food and money slowly became scarce, and discontent among the populace began to emerge. As early as August, a group of members of the Abbasid family complained to Muhammad b. 'Abdallah that their stipends were not being paid. As conditions in the city deteriorated, Muhammad gradually became convinced that victory through force of arms was impossible. By November at the latest, and without the knowledge or permission of al-Musta'in, he had opened negotiations with al-Mu'tazz regarding al-Musta'in's surrender.

Muhammad and al-Mu'tazz had already started negotiating with each other when the former launched his failed sally. After the battle, al-Mu'tazz criticized Muhammad for acting in bad faith, and the Samarran army intensified the siege. Soon the city was running low on resources. Crowds began appearing before Muhammad's palace, crying "hunger!" and demanding a resolution to their problems. Muhammad held off the crowds with promises, and at the same time sent an offer of peace to al-Mu'tazz. This was responded to favorably, and beginning on December 8 a representative from Abu Ahmad's camp began meeting Muhammad in private to discuss how to end the conflict.

As the siege progressed into December, the population of Baghdad became more agitated. On December 16, some of the regular infantry and commoners gathered together, with the former demanding their pay and the latter complaining about how food prices had skyrocketed. Muhammad was able to convince them to temporarily disperse, but riots broke out in the city two days later and it was only with difficulty that they were quelled. Meanwhile, negotiations between Muhammad and Abu Ahmad continued; emissaries were sent by Muhammad to Abu Ahmad's camp, and Samarran prisoners of war were released. Toward the end of December, a provisional agreement between the two sides to depose al-Musta'in was reached, and Abu Ahmad sent five ships loaded with foodstuffs and fodder to relieve the shortages in the city.

When the citizens of Baghdad learned that Muhammad had agreed to depose al-Musta'in, they angrily assembled outside his palace. Out of loyalty to al-Musta'in and fears that Muhammad's surrender could result in the Samarrans plundering the city, they attacked the palace gates and fought against the guards. In order to calm the protestors, al-Musta'in appeared above the palace gate with Muhammad at his side, and he gave assurances to the crowd that he was still caliph and that he would lead the Friday prayers the next morning. The following day, December 28, he failed to appear; in response, the houses of Muhammad's subordinates were looted and a large crowd again approached Muhammad's palace, forcing al-Musta'in to make another public appearance. Shortly after this he moved out of Muhammad's palace to another residence in the city, and on January 2, 866, he led the prayer for the Feast of Sacrifice.

Muhammad, for his part, strove to convince the people that he was still acting in al-Musta'in's best interests, while at the same time continuing to negotiate with Abu Ahmad regarding the terms of surrender. On January 7, Muhammad and Abu Ahmad met in person under a canopy outside the Shammasiyah gate, and the two men agreed that the state revenues would be split among the parties, with two thirds going to the Turks and one third going to Muhammad and the Baghdadi army, and al-Musta'in should be held liable for part of the soldiers' pay. On the following day, Muhammad went to al-Musta'in and attempted to convince him to abdicate. At first al-Musta'in adamantly refused, but when the Turkish officers Wasif and Bugha stated that they had sided with Muhammad, he agreed to step down.

As part of the terms of al-Musta'in's abdication, he was to be given an estate in the Hijaz, and allowed to travel between the cities of Mecca and Medina. On January 12, Muhammad brought a group of judges and jurists to witness that al-Musta'in had entrusted his affairs to him. Delegates carrying the terms of abdication were sent to Samarra, where al-Mu'tazz personally signed the document and agreed to the conditions. The delegates returned to Baghdad with the signed document on January 24, accompanied by a group of emissaries sent to secure al-Musta'in's allegiance to al-Mu'tazz. On Friday, January 25, al-Mu'tazz was acknowledged as caliph in the mosques throughout Baghdad.

Aftermath
The outcome of the war did nothing to solve the problems that had been responsible for it in the first place. The revenues of the state were still massively insufficient to pay the soldiers' salaries, causing violence to break out among the troops. The military continued to demand complete control over the affairs of the state, and met with hostility the attempts to the caliphs to reduce their authority. As a result, the government soon reverted to the state of instability it had been in before the war.

The war was, at least economically speaking, extremely destructive for the empire. The costs of campaigning for both sides, including paying for soldiers' and officers' salaries and other wartime expenses, was enormous. The cutting of the canals around al-Anbar contributed to a long term economic decline in the region, and the numerous acts of plunder and forcing people from their fields disrupted the productivity of the empire's richest province, putting additional financial strain on the state. Baghdad was devastated, with the eastern side of the city never fully recovering from the damage it incurred during the war. Within the city, the populace had gone several months without adequate supplies, and price inflation and deprivation became common. The human cost of the war is difficult to determine, since no comprehensive casualty figures are mentioned, but at the very least it ranged in the thousands.

In spite of the terms of abdication, al-Musta'in was not allowed to go into exile to the Hijaz, but was instead moved to Wasit. In October 866 he was ordered to travel to Samarra, but on October 17, when he had arrived in the vicinity of the city, he was intercepted by a group of men sent to kill him and was quickly executed.

Al-Mu'tazz's caliphate after the war was to prove to be short and violent. His brothers Abu Ahmad, who had been responsible for his victory in the war, and al-Mu'ayyad were both thrown in prison in 866, with al-Mu'ayyad dying a short time later. Meanwhile, infighting among the military soon flared up again, and numerous officers, including Wasif and Bugha, were killed. Finally, due to the inability of the caliph to pay them, in July 869 a group of Turkish, North African and Ferghanan soldiers forced al-Mu'tazz to abdicate and he died from maltreatment a few days later.

The only member of the Abbasid family to benefit from the conflict in the long term was Abu Ahmad. He developed strong connections with the Turkish leadership, and this relationship was what possibly prevented al-Mu'tazz from killing him when he was imprisoned the following year. In spite of his imprisonment and subsequent exile, he remained a powerful figure in the government and was a possible contender for the caliphate in 869. From the ascension of al-Mu'tamid in 870, he was the de facto ruler of the empire with the title of al-Muwaffaq, although he never formally became caliph. Thanks to his close ties to the Turks, he became the chief military commander of the state. His son al-Mu'tadid actually did become caliph in 892, and all subsequent Abbasid caliphs were descended from him.

Al-Musta'in's defeat resulted in Samarra remaining the capital city of the caliphate. It would continue to serve as such until 892, during the caliphate of al-Mu'tadid; thereafter the seat of the caliphs remained at Baghdad.