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.
[6] 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.
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.
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.
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.
Ballistas and mangonels were installed on the walls, and "war engines" designed to hinder enemy movement were placed in front of the city gates.
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.
At first they were given mats to protect themselves and bags of rocks or bricks to attack the enemy with;[19] later they were given clubs, placed under their own chief and registered in the military roll so that they could be paid.
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.
[29] 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.
'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.
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.
[36] 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.
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.
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.
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 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.
[46] In Samarra, meanwhile, plans were developed to attack al-Anbar, and soon al-Mu'tazz sent a force of Turks and North Africans under Muhammad ibn Bugha to take the town.
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.
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.
[53] 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.
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.
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.
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.
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.
[62] Muhammad, for his part, strove to convince the people that he was still acting in al-Musta'in's best interests,[63] while at the same time continuing to negotiate with Abu Ahmad regarding the terms of surrender.
The cutting of the canals around al-Anbar contributed to a long term economic decline in the region,[70] and the numerous acts of plunder and forcing people from their fields disrupted the productivity of the empire's richest province,[71] putting additional financial strain on the state.
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.