Reign of al-Mutawakkil (r. 847–861)
Partly due to renewed Zaydite Shia opposition, al-Mutawakkil persecuted Mu'tazilites and Shias, to the point that even Sunni sources have noted his hostility towards Shias. The caliph may have imposed the penalty of death by flagellation on anyone who defamed the companions or the wives of the prophet, some of whom are viewed negatively in Shia. He also openly cursed Ali ibn Abi Talib and ordered a clown to ridicule Ali in his banquets, writes the Twelver scholar Muhammad Husayn Tabatabai (d. 1981). By his orders, the shrine of Ali's son, Husayn ibn Ali (d. 680), was demolished in Karbala, water was turned upon the tomb, and the ground was plowed and cultivated to remove any trace of the tomb, so as to stop Shia pilgrimages to the site, which he also outlawed.
The campaign of arrests and torture by al-Mutawakkil in 846 led to the deaths of some associates of Ali al-Hadi in Baghdad, al-Mada'in, Kufa, and the Sawad. These were replaced by new representatives, including Hasan ibn Rashid and Ayyub ibn Nuh. The policies of al-Mutawakkil also pushed many Alids in the Hejaz and Egypt into destitution. The caliph is said to have punished those who traded with the Alids, thus isolating them financially. The village of Fadak, which had previously been returned to the Alids by al-Ma'mun, was now confiscated by al-Mutawakkil and awarded to a descendant of the early caliph Umar (r. 634–644), named as Abd Allah ibn Umar al-Bazyar. The caliph also dismissed officials suspected of Shia sympathies, including the governor of Saymara and Sirawan in the province of Jibal. As the governor of the holy cities in the Hejaz, al-Mutawakkil appointed Umar ibn Faraj, who prevented Alids from answering religious inquiries or accepting gifts, thus pushing them into poverty. The caliph also created a new army, known as Shakiriyya, which recruited from anti-Alid areas, such as Syria, al-Jazira (Upper Mesopotamia), the Jibal, the Hejaz, and from the Abna, a pro-Abbasid ethnic group. He implemented these policies with the help of his officials, particularly Ahmad ibn al-Khasib al-Jarjara'i (d. 879) and al-Fath ibn Khaqan (d. 861).
It was during the caliphate of al-Mutawakkil that the governor of Medina, Abd Allah ibn Muhammad, wrote to the caliph and warned him about the subversive activities of al-Hadi, claiming that he had concealed arms and books for his followers. Alternatively, Ithbat attributes the affair to Burahya al-Abbasi, the leader of prayers in Medina, who may have advised the caliph to remove al-Hadi from the city because he was allegedly agitating against the caliph. When al-Hadi learned about the allegations, he too wrote to al-Mutawakkil and defended himself. The caliph responded respectfully but also requested that he with his family relocate to the new Abbasid capital of Samarra, a garrison town where the Turkish guards were stationed, north of Baghdad. This letter also announced the dismissal of Abd Allah from his post in Medina, and is recorded in Kitab al-Irshad and Kitab al-Kafi, a comprehensive collection of Shia hadiths by the prominent Twelver scholar Muhammad ibn Ya'qub al-Kulayni (d. 941). The Islamicist Wilferd Madelung suggests that the letter is authentic, while Wardrop views the reverential and conciliatory tone of the letter as an indication that the caliph was cautious not to provoke an Alid rebellion in Medina, even though there is no evidence that al-Hadi actually intended to revolt. The Muslim academic Jassim M. Hussain suggests that al-Hadi was summoned to Samarra and held there because the investigations of caliph's officials, including Abd Allah, had linked the Shia Imam to the underground activities of the Imamites in Baghdad, al-Mada'in, and Kufa. The caliph thus decided to follow the policy of his predecessor, al-Ma'mun, who had attached the imams al-Rida and al-Jawad to his court in order to monitor and restrict them.
The caliph's letter was probably dated Jumada II 233 AH (January 848), but transmitted incorrectly as Jumada II 243 AH (October 857) by al-Mofid, the author of al-Irshad. Both Wardrop and Madelung consider the latter date unlikely, while the first date is also corroborated by Bihar, which states that al-Hadi spent twenty years of his life in Samarra. The escort who accompanied al-Hadi to Samarra is named variously in different sources as Yahya ibn Harthama, Yahya ibn Hubayra, or Attab ibn Abi Attab. The account of al-Mas'udi adds that this escort searched the residence of al-Hadi in Medina, without finding any evidence of subversion. He also calmed the public disorder by ensuring the locals that al-Hadi would not be harmed. A similar report is given by the Sunni historian Ibn Khallikan (d. 1282).
When al-Hadi approached Baghdad, people gathered to see him and he was received warmly by the governor, Ishaq ibn Ibrahim al-Mus'abi, who welcomed him outside of the city. Later, when al-Hadi arrived in Samarra on 23 Ramadan 233 AH (1 May 848), the caliph did not immediately receive him but assigned a house for him, located in the al-Askar (lit. 'the army') quarter of the city, which was mostly occupied by the army. More specifically, his residence was in the center of the city on Abi Ahmad Street. Having escorted al-Hadi to Samarra, Yahya conveyed to the caliph the recommendations of al-Tahiri and the Turkish commander Wasif al-Turki, which apparently convinced the caliph to treat al-Hadi honorably. Still, there is a report that al-Hadi was temporarily placed under house arrest after his arrival in Samarra.
Ali al-Hadi lived in Samarra under constant surveillance until his death, some twenty years later. Among modern authors, Edward D. A. Hulmes, Moojan Momen, Hamid Mavani, and Reza Aslan liken al-Hadi to a prisoner in this period. In particular, he could rarely meet with ordinary Shias, as suggested by the scarcity of such reports in the early sources. For instance, Bihar describes a group of eager visitors for al-Hadi, who nevertheless had no idea what their imam looked like. The reports about this period depict a persecuted al-Hadi, who suffered frequent attempts by al-Mutawakkil and others at the court to belittle and dishonor him. More seriously, there is some evidence that al-Mutawakkil at least once attempted to kill al-Hadi during this period. Tabatabai and the Muslim academic Abdulaziz Sachedina go further, writing that the caliph on multiple occasions was intent on killing al-Hadi and had his house searched. Sachedina believes that fear of public unrest prevented al-Mutawakkil from killing al-Hadi, who was recognized by this time as a pious and learned figure.
In contrast, Madelung quotes al-Hadi as saying that he had not come to Samarra voluntarily but would never leave the city, as he liked its good water and air. His view is that al-Hadi was allowed to move freely within the city, and continued to send (written) instructions for his representatives across the Abbasid empire and receive through them the donations of Shias. Sachedina views this freedom of movement as an indication that al-Hadi did not pose a serious threat, while Wardrop suggests that the passive spiritual excellence of the Shia Imams was probably considered a more serious threat than an armed rebellion which could be easily crushed.
That al-Hadi remained in contact with his followers is also the opinion of the Islamicists Farhad Daftary, Sachedina, and Hussain, but the last author believes that al-Hadi sent and received his messages with secrecy, under the watchful eyes of the caliph. For Wardrop, a certain cycle of honor and suspicion was probably inevitable at the court of al-Mutawakkil. Still, in the case of al-Hadi as a Shia Imam with an active following, the image offered by Twelver sources is heavily tilted towards suspicion and persecution. Wardrop also notes that most reports about al-Hadi are attributed to this period, perhaps because al-Hadi was more "newsworthy" in Samarra, being close both to the center of power and to the large Shia population of Iraq. In her view, many of these reports might be exaggerated but they are likely based on truth and thus unwise to ignore.
Wardrop also studies a few representative accounts about al-Hadi from this period: Kitab al-Kafi reports that al-Mutawakkil ordered to search the residence of al-Hadi at night on a tip by al-Batha'i, an Alid supporter of the caliph. The search did not turn any evidence of subversive activities and the money seized was later returned to al-Hadi. After the search, a relieved al-Mutawakkil invited al-Hadi to drink wine with him late at night. The latter refused and instead recited some poetry, the moral theme of which moved the caliph to tears. Accounts of futile searches appear also in Muruj by al-Mas'udi and in Wafayat al-a'yan by Ibn Khallikan. Shortly before the overthrow of al-Mutawakkil in 861, a temporary imprisonment of al-Hadi is reported in I'lam by the Twelver historian al-Tabarsi (d. 1153) and in Bihar, under the custody of one Ali ibn Karkar. The caliph may have ordered his close advisor Ibn Khaqan to poison the imprisoned al-Hadi. Also dated 861, the biographical al-Khara'ij by the Twelver scholar Qutb al-Din al-Rawandi (d. 1178) similarly reports a house arrest of al-Hadi under Sa'id al-Hajib, who was allegedly ordered to kill the Imam. In his report, a visitor finds al-Hadi seated next to an open grave in his house but is reassured by him that he would not be harmed because al-Mutawakkil would die shortly. Ithbat reports that the prayer of al-Hadi in the palace was once interrupted by a member of the court who accused him of hypocrisy. In an official banquet to which he was invited, al-Hadi silenced a man who continued to loudly interrupt him by predicting his imminent death, reports Bihar. A report on the authority of Zurara, a member of the court, states that the caliph offered a reward to anyone who would embarrass al-Hadi. The offer was taken up by an Indian knowledgeable of various sleights of hand, the report continues, who arranged for the loaves of bread to move away when al-Hadi reached for them, bringing the crowd to laughter. Bihar reports that al-Mutawakkil temporarily forbade his staff from serving al-Hadi, advised by a relative nicknamed Harisa, who warned the caliph that this was boosting the political image of al-Hadi among people. This Twelver report has a miraculous ending with the caliph abandoning his policy after an unexpected breeze blew the curtains open for al-Hadi instead of the guards.