Samarra exists because the caliph al-Mutasim needed somewhere to put his Turkish soldiers. Their presence in Baghdad had become intolerable to the population, and in 836 he moved the court and the troops upriver to a new site, where successive caliphs then built palaces, barracks, racecourses and mosques along some thirty kilometres of the Tigris. The capital returned to Baghdad after about half a century, and the site was largely abandoned, which is why it survives as the largest archaeological city of the Islamic world and was inscribed on the World Heritage list in 2007.
Its most recognisable building is the Great Mosque of al-Mutawakkil, at its completion the largest mosque anywhere, with a free standing spiral minaret climbed by an external ramp. Nothing else quite like it was built again.
Samarra was also where the state tried to settle a doctrinal question by force and failed. The inquisition begun under al-Mamun required scholars to affirm that the Quran is created rather than eternal, a Mutazili position, and those who refused were imprisoned or beaten. Ahmad ibn Hanbal's refusal made him a hero of the traditionist party. Under al-Mutawakkil the policy was reversed entirely, the Mutazila lost official favour, and the episode is generally read as the moment the caliphate ceded the definition of orthodoxy to the scholars, who have held it since.