Ahmad ibn Muhammad (; 836 – 17 October 866), better known by his regnal name (, "He who looks for help to God") 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 Turkish military leaders held a council to select his successor. They were not willing to have al-Mu'tazz or his brothers; so they elected al-Musta'in, a grandson of al-Mu'tasim.
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 Turkish 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.
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 Turkish and Berber troops, resigned their titles to succeed, and were then, by way of protection, kept in confinement. After a second attempt to overturn the decision made by the Turks, Al-Mu'tazz and his brother would have been put them both by the Turks, but the vizier interposed and saved their lives, for which act of mercy, his property was seized by the Turkish soldiers, and himself banished to Crete. The Empire, in fact, both at home and abroad, had passed into the hands of Turks.
In 863, the Muslim campaign against the Christians was going badly. Two whole corps in Armenia and Asia Minor, some 8,000 strong, with their leaders, were killed during the Battle of Lalakaon. The tidings created anger and riots in Baghdad. The ancient cry for a Holy War rang through the streets. People blamed the Turks that had brought disaster on the faith, murdered their Caliphs, and set up others at their pleasure.
With such cries the city rose in uproar; the prisons were broken into and bridges burned. But Baghdad could no longer dictate to its rulers; it could only riot. The fighting spirit was, however, strong enough to draw men from the surrounding provinces, who flocked as free lances to fight against the infidel. But the Turks cared for none of these things, nor did the Caliph.
In 864, his forces put down a rebellion by the Alid Yahya ibn Umar and a revolt in Hims.
In 865, the end for al-Musta'in himself was now at hand. After some disagreements between the Turkish leaders that placed al-Musta'in in much danger, he, along with two other Turkish leaders, Bugha al-Sharabi and Wasif, left Samarra on a boat to East Baghdad. The Turks sent after him a party of their captains, requesting him to return to Samarra. But the Caliph refused, and hard words followed between the two sides, in the heat of which one of the Turkish speakers received a blow.
The insult rankled the Turkish officers, and on returning to Samarra, the Turkish troops rose together, and bringing forth al-Mu'tazz from his confinement, saluted him as Caliph. Within a few weeks, his brother Abu Ahmad al-Muwaffaq, with 50,000 Turks and 2,000 Berbers, besieged Baghdad, a siege that would last throughout the year 865.
By the beginning of 866, with plots and treachery all around, al-Musta'in was persuaded by alternating threats and promises to abdicate in favor of al-Mu'tazz. He was to live at Medina with a sufficient income. The conditions signed, the Governor of Baghdad received the ministers and courtiers of al-Musta'in, and having assured them he had done what he had for the best and to stop further bloodshed, sent them to Samarra to pay homage to the new Caliph. al-Mu'tazz ratified the terms and took possession of Baghdad in the early days of 252 AH (866 CE). He also sent to al-Musta'in his mother and family from Samarra, but not until they had been stripped of everything they possessed.
Instead of finding a refuge at Medina, al-Musta'in found himself kept in Baghdad. There he was put to death on 17 October 866 by the order of al-Mu'tazz. Carrying al-Musta'in's head to the Caliph, "Here," cried the executioner, "behold thy cousin's head!" "Lay it aside," answered al-Mu'tazz who was playing chess,—"till I have finished the game." And then, having satisfied himself that it was really al-Musta'in's head, he commanded 500 pieces to be given to the assassin as his reward.
Al-Musta'in Billah ( 1390 – February or March 1430) was the tenth Abbasid "shadow" caliph of Cairo, reigning under the tutelage of the Mamluk sultans from 1406 to 1414. He was the only Cairo-based Abbasid caliph to hold political power as Sultan of Egypt, albeit for only six months in 1412. All the other Cairene Abbasid caliphs who preceded or succeeded him were spiritual heads lacking any temporal power.