Answered by Sayyidi Habib Umar bin Hafiz (may Allah protect him and benefit us by him)
Thoughts of disbelief sometimes come into my mind. Does this take me out of the fold of Islam?
No this does not take you out of the fold of Islam. We are only taken to account for the thoughts which we are content with and agree with. We will not be taken to account for the thoughts which you dislike and ignore. This is a manifestation of Allah’s bounty. The Prophet said ﷺ : “Allah has overlooked for my sake my nation’s mistakes, forgetfulness and thoughts as long as they do not talk about it or act upon it.”
One way of driving these thoughts away is to repeat Allah’s name lengthening the ‘a’ (Allaaaah) and raising the head upwards towards the sky.
There is nothing better than imploring Allah for His assistance and remembering Him constantly. Anyone who feels that they are unable to purify themselves should turn to Allah and say (as Imam al-Haddad says):
يا رَبِّ قَدْ غَلَبَتْنِي وَبالأَمَـانِي سَبَـتْنِي
وَفِي الْحُظُوْظِ كَبَتْنِي وَقَيَّــدَتْنِي بَالاكْبَــالْ
قَـدْ اسْـتَعَنْتُكَ رَبِي عَلَى مُــدَاوَاة قَلْبِيْ
وَحَـلِّ عُقْـدَة كَرْبِـي فَانْظُرْ إِلَى الْغَـمِّ يَنْجَـالْ
My Lord, my lower self has overpowered me
And deluded me with false hopes,
It subdues me with worldly pleasures,
and shackles me in chains.
I seek Your support, my Lord,
in curing my heart.
Release me from distress and look
(kindly) on my sorrow and dispel it.