Abū al-ʿAbbās Aḥmad ibn Muḥammad ibn Muḥammad (; 836 – 17 October 866), better known by his regnal title al-Mustaʿīn (836 – 17 October 866) was the Abbasid caliph from 862 to 866, during the "Anarchy at Samarra". After the death of previous Caliph, al-Muntasir (who had not appointed any successors), the Turkic military leaders held a council to select his successor. They were not willing to have al-Mu'tazz or his brothers; so they elected Ahmad ibn Muhammad (), a nephew of al-Mutawakkil, who took the regnal name al-Mustaʿīn bi-ʾllāh ( "he who looks for help to God"). Arab and other troops based in Baghdad, displeased at the choice, attacked the assembly, broke open the prison, and plundered the armory. They were attacked by the Turkic and Berber soldiers, and after some fighting in which many died, succumbed. Baghdad had yet to learn that the Caliphate no longer depended on the opinions of the Arabians, but had passed into other hands. Birth and background Ahmad ibn Muhammad (future al-Musta'in) was the son of Abbasid prince Muhammad ibn al-Mu'tasim and his mother was a concubine from province of Sicily called Makhariq. Al-Musta'in was the grandson of caliph al-Mu'tasim (r. 833–842) . He was the nephew of caliph al-Wathiq (r. 842–847) and caliph al-Mutawakkil (r. 847–861). His uncle, caliph al-Mutawakkil (r. 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 December 861 al-Mutawakkil was assassinated by a group of Turkic military officers, likely with the support of al-Muntasir. During al-Muntasir's short reign (r. 861–862), the Turks pressured him into removing al-Mu'tazz and al-Mu'ayyad from the succession. When al-Muntasir died, the Turkic officers gathered together and decided to install the dead caliph's cousin al-Musta'in on the throne. Reign 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. The governor of Baghdad persuaded the city to submit, and the succession was thereafter acknowledged throughout the land. Al-Mu'tazz and his brother, threatened by the Turkic and Berber