When Mutawakkil (the Abbasid Caliph) whom his hatred to the Ahl al-Bayt (PBUT) and their followers is evident, became the Caliph he feared that Imam Hadi (PBUH) rise against him. Therefore he bade Imam Hadi (PBUH) to reside near him to keep him under his scrutiny so that if necessary could impose pressure on him, and whenever needed murder him. However, Imam (PBUH), by the will of Allah (SWT), prudently decided to use the opportunity to infiltrate his influence into the government and the inner circle of the Caliph, and he succeeded in doing so. Incidents such as the following can illustrate the aspects of influence of Imam Hadi (PBUH) in the court.
In the court of Mutawakkil, some had gossiped about Imam Hadi (PBUH) and had said that he had received letters and arms from his followers at Qum, and that he had plans to overthrow Mutawakkil and seize power.
Mutawakkil sent some of his soldiers to the house of Imam Hadi (PBUH). They attacked his house at night, but could not find anything, and found Imam (PBUH) in a room alone sitting on the soil, wearing a woolen cloth in prayers, and reciting the Holy Quran. The soldiers took him to the Castle straight away, and said to Mutawakkil, “Nothing was found at his house, and we saw him sitting to the direction of Qiblah, and reciting the Holy Quran." Mutiwakkil was drinking wine and there was a glass of wine in his hands. When he saw Imam (PBUH), he caused Imam to sit next to him offering him his glass of wine.
Imam Hadi (PBUH) said, “By Allah my flesh and blood have never tasted wine, excuse me."
Mutawakkil then took back his offer and then asked the Imam to recite a poem. Imam (PBUH) answered, “I know very few poems."
Mutawakkil said, “No problem." Imam (PBUH) while sitting close to Mutawakkil started reciting the following verses:
“(The powerful and oppressor kings) would spend the night at top of the mountains, while powerful men were protecting them; yet the mountain peaks could not save them (from the danger of death.)
After times of glory and honor, they were pulled down from their fortress, and settled in pits (graves); oh, what a bad place they descended to!"
When they were buried in the ground, someone shouted, “Where are those bracelets, crowns, and costly clothing?
Where are those delicately brought up faces that were respected through the hanging curtains (they had palaces and doorkeepers)?"
Their graves answer instead of them, “Now, the worms are competing with each to eat the features!"
They ate and drank a long time in this world; but now, they that were eaters of all things are themselves being eaten by worms and insects!
What houses they built to protect themselves from dangers! But eventually, after some time, they said farewell to these houses and families and hurried into their tomb residence.
What wealth and reserves they had stored, but left all of them for the enemies.
Their houses and palaces turned into ruins and their residents hurried toward dark graves!"
Mutawakkil heard these poems and started to weep until he had his beard wet. The audience cried too. Then they returned Imam Hadi (PBUH) to his house with great respect.
Source: "Guiders of the path of light – Life of Imam Hadi (PBUH)", by Ayatullah Sayyed Muhammad Taghi al-Modarresi