Praise be to Allah.
Take it easy, for the matter is much easier than you think.
What you are suffering is like a shadow that grows bigger until it covers the entire wall, because the source of light has been placed in the wrong position. If the source of light is moved to the right position, the shadow will be reduced to the right size.
In either case, there is nothing harmful, great or small, in the shadow.
Your situation is no more than a shadow, so take it easy.
The Shaytaan cannot take away your faith, because the one who gives faith and takes it away is Allah. If Allah protects you, you will be safe from all harm.
If you want to be relieved of all these troubles that the Shaytaan is causing you, then you must strengthen your resolve and do the following:
1.. Seek refuge with Allah every time one of these thoughts crosses your mind, and do not falter, for the Shaytaan will inevitably be defeated and flee. This is a true promise from Allah (interpretation of the meaning): “And if there comes to you from Satan an evil suggestion, then seek refuge in Allah. Indeed, He is the Hearing, the Knowing” [Fussilat 41:36].
2.. Ignore these intrusive thoughts and do not think about them at all; do not dwell on them or try to answer any question posed by these intrusive thoughts.
Do not yield to any threat from the Shaytaan or let him scare you with disbelief, misguidance or hellfire.
Do you know why? Because these threats have no effect on the level of your faith and none of that will happen to you.
It is like scary scenes on a TV screen that do not harm the viewer, and when you turn the TV off everything disappears.
3.. Fill your time, your thoughts and your heart with that which is beneficial and useful, and mix with good people, for perhaps you are suffering because of having too much free time or being lonely. The Shaytaan does not come near a vessel that is full.
4.. Offer supplication (du‘aa’) night and day, for when the healing of Allah comes, it does not leave behind any sickness or trouble but it resolves it.
5.. Fortify yourself with the remembrance of Allah throughout the night and at the ends of the day, at every moment, for there is nothing better with which to protect oneself from the schemes of one’s enemy than the remembrance of Allah, may He be exalted, and being steadfast in that. So keep your tongue moist with the remembrance of Allah.
6.. In addition to these spiritual remedies, you must consult a competent specialist doctor, for in the case of compulsive intrusive thoughts, there are medicines which may be beneficial by Allah’s leave, and if you combine the two remedies – spiritual and medical, that will be more beneficial for you, and more likely to lead to healing, by Allah’s leave.
If you follow this advice and persist in striving to control your nafs, then glad tidings of recovery will soon come, by Allah’s leave, and will increase hour after hour, until you are completely healed within a few days, by the help of Allah.
May Allah make you steadfast in faith and bestow upon you well-being and forgiveness.
And Allah knows best.