The desire of caliphs to achieve absolute authority over their dominion came into a conflict with the structure of Arab society. Tribal and clan allegiances, predating the birth of Islam itself, let alone ascension of Abbasid dynasty, prevailed over any allegiance Arab subject may give to caliph. Thus, Caliphate needed the source of loyal servants, especially in military ranks.
Over the time, caliphs had tried different approaches to this problem, mostly relying to administrators from newly conquered peoples, rather than Arabs. Sure, Persian or Greek had no friends among the Arab aristocracy, his only friend and protector was the caliph himself.
And then one man decided that rather than trying to purchase men’s loyalty, he’d better purchase the men themselves. Enter Abū Isḥāq Muḥammad ibn Hārūn al-Ras̲h̲īd, better known by his throne name, al-Mu’tasim Bi’llah. While his brother, caliph al-Ma’mun, practiced astronomy and was trying to get into Cheops’ pyramid, al-Mu’tasim begun purchasing Turkic warrior-slaves. These warriors became known as “Mamlukes” (Arab for “property”) or Ghilman (Arab for “young servant”)
After his brother’s death in 833, al-Mu’tasim quickly ascended the throne, with non-surprisingly little opposition. Would you want to oppose person who have 15 000 strong army, officers and all, as his private property?
At first these mamlukes were stationed in Baghdad itself, but that quickly proved troublesome. Good citizens of Baghdad were not too happy leaving around what they saw as unruly mob of barbarians, and mamlukes, mostly Turks, answered only to caliph himself, gladly abused their position andterrorized citizenry. And so the new capital city of Samarra was built.
Fast forward to the year 861.
Turks achieved dangerous level of control over the caliphal court, army and state as a whole. When caliph Al-Mutawakkil tried to move capital from Samarra, they just didn’t let him. Mutawakkil started slowly fight Turkic influence in the army, by, see if you can guess it, purchasing warrior-slaves of non-Turkic ethnicity, Berbers of North Africa, Armenians and peoples of Caucasus.
On the unrelated note, in 850 Mutawakkil named his son al-Muntasir as heir apparent, but over the years something happened between them, and Mutawakkil chose his other son, al-Mu’tazz.
This was a match made in heaven. In the year of 861, Turkic bodyguards murdered al-Mutawakkil and proclaimed al-Muntasir caliph, al-Mutazz was forced to abdicate.
But in the summer of the same year al-Muntasir died of unknown reason. Turks, despite the order of succession, proclaimed al-Mu’tasim’s grandson,al-Mustain.
Al-Mutazz didn’t recognize that, and was proclaimed caliph in Baghdad. Did I mention that while Tukic commanders were playing kingmakers, average Turkic soldiers weren’t paid for two years? Yes, that bound to simplify matters.
The following civil war of 865-866 had so many betrayals, side-switching and other fun, that it’s incredibly hard to tell about in a few sentences. So, fast forward to 867: Al-Mutazz is caliph, murdering everybody he deems dangerous, but extremely dependent on his army, Turkic, of course, they switched sides. Not once. Provinces, like Ifriqiya, Iran and Egypt are effectively independent. Bands of Turkic, Berber and other warriors roaming the roads of Caliphate, while in the cities Arab mob is murdering anyone who looks too Turkic. Desert Bedouin tribes raid settled lands without any other justification, but their ability to do so. There is no money in the treasury and so on, so on.