Shaykh al-Islam [Ibn Taymiyah] (may Allaah have mercy on him) said: “A calamity that makes you turn to Allaah is better for you than a blessing which makes you forget the remembrance of Allaah.”
Sufyaan said: What a person dislikes may be better for him than what he likes, because what he dislikes causes him to call upon Allaah, whereas what he likes may make him heedless.
Ibn Taymiyah (may Allaah have mercy on him) regarded his imprisonment as a blessing that had been caused by his enemies.
Ibn al-Qayyim said: One day he – meaning Ibn Taymiyah – said to me: What can my enemies do to me? My garden is in my heart; wherever I go it is with me and never leaves me. My detainment is seclusion (an opportunity for worship), my being killed is martyrdom, and being expelled from my city is a journey.
He used to say of his detainment in the citadel: If I were to spend the fill of this citadel in gold, that would not be sufficient to express my gratitude for this blessing. Or he said: That would not be sufficient to reward them for what they have brought to me of goodness.
When he was imprisoned, he used to say when prostrating: “O Allaah, help me to remember You, give thanks to You and to worship You well. Ma sha Allaah. He said to me (Ibn al-Qayyim) one day: The one who is really detained is the one who keeps his heart away from his Lord, and the real prisoner is the one is captive to his whims and desires. When he entered the citadel and was within its walls, he looked at it and said: “So a wall will be put up between them, with a gate therein. Inside it will be mercy, and outside it will be torment” [al-Hadeed 57:13]. Allaah knows that I have never seen anyone who was more content with his life than him, despite all the hardship that he experienced, and the lack of luxury and comfort, in fact the opposite of that, and despite the imprisonment, threats and exhaustion that he faced; despite all of that, he was the happiest of people with his life, the most content, the most courageous, the most satisfied. You could see the signs of joy and happiness in his face. When we felt afraid and were expecting calamity, and we had nowhere to turn, we would go to him and as soon as we saw him and heard his voice, all those fears disappeared and were replaced with contentment, courage, certainty and tranquillity. Glory be to the One who showed some of His slaves His Paradise before they met Him, and opened its gates to them when they were still in this world of deeds and actions, so some of its breezes and fragrance came to them, which made them devote their energy to seeking it and competing in attaining it.
Al-Waabil al-Sayyib (p. 110).