Samarra was founded by the eighth Abbasid caliph al-Mu'tasim (r. 833–842) in 836. Al-Mu'tasim's immediate motivation for the decision was a need to find housing for his newly formed Turkish and other army regiments. These troops, who were from groups that had previously held only a marginal role in the Islamic world, were deeply unpopular among the residents of Baghdad, and violent incidents had repeatedly broken out between the soldiers and Baghdadis. Al-Mu'tasim therefore resolved in ca. 835 to depart from Baghdad, the usual seat of the Abbasid caliphs since 762, and create a new capital city of his choosing.