In 220 AH (forty years before The Minor Occultation Era), Muʿtaṣim’ ‘Abbasi chose Sāmarrāʾ as his new capital
So, he built and made it his center of caliphate.
He bought more than 4000 slaves whom he ordered to wear splendid clothes. [with them, they looked superior than other armies]
They used to ride in Baghdad streets and by markets,
bother the people and sometimes kick them with their horses.
About the main reason of build Sāmarrāʾ, Ibn Athīr (one of the famous historians) wrote:
In 220 AH, Muʿtaṣim went to Sāmarrāʾ to build a city there. He did so because he had mentioned,
‘I am afraid of armies! If they rebel, they will kill all of slaves. I prefer to be in a location which I can overlook them.’
From 230 to 279 AH (for 59 years), The Abbasid Caliphate Center was transferred from Baghdad to Samarra.
But in 279 AH, the caliphate returned to Baghdad.
[Now in 279 AH], Imam Mahdī (mgehr) is 24 and it is 19 years after The Minor Occultation…
Subsequently, the city of Sāmarrāʾ quickly turned into ruins, with only two graves of Imam Hādī and Imam al-Askari (pbu th), and also The Holy Sardab1 still remained there.
***
1- It was a cellar in the northwest of the shrine of `Askariin (pbu th), in Sāmarrāʾ. It was the residence and worship place for Imam Hādī and al-Askari (pbu th) during the hot summer days. According to reports, Imam Mahdī (mgehr) was also seen there, in the time of his father’s life. That is the reason for naming the place “The Holy Sardab”, in The Occultation Era.
…
Moravej al-Zahab, Vol. 4, P. 53; Tarikh al-Khulafa, P. 335; Al- Kāmil, Vol. 6, P. 451; Mu’jam al-buldan, Vol. 3, P. 176