Short answer
No, not if they are unwanted thoughts that you hate. When Companions complained of thoughts too awful to say, the Prophet ﷺ said that finding them so awful is "clear faith". Allah does not hold you to passing thoughts you do not act on or speak. Seek refuge in Allah, stop engaging with them, and carry on.
Waswasa (intrusive whispers) that you dislike is not a sin and does not harm your iman. Kufr happens only when a person chooses disbelief in the heart or speaks it knowingly by choice. People who suffer this repeatedly should speak to a scholar and, if it is compulsive, to a doctor.
The four schools agree on this.
Explanation
Some people get sudden thoughts that insult Allah, doubt Him, or picture something disrespectful, and they are terrified it has made them leave Islam. You are not the first. Some Companions came to the Prophet ﷺ and said they found thoughts in themselves so serious that none of them would dare speak them. He asked, "Do you really find that?" They said yes. He said, "That is clear faith" (Sahih Muslim). The disgust you feel is the faith.
The Prophet ﷺ also said Shaytan comes to one of you and says, "Who created this? Who created that?" until he says, "Who created your Lord?" When it reaches that point, seek refuge in Allah and stop (Sahih al-Bukhari). He did not tell them to argue with the thought. He told them to cut it off.
And he said Allah has overlooked for his ummah what their selves whisper to them, as long as they do not act on it or speak it. The Quran says, "Allah does not charge a soul except with that within its capacity" (2:286). An unwanted thought is not within your control, so you are not blamed for it.
What helps:
- Say a'udhu billah, then turn your attention to something else.
- Do not keep testing yourself or retaking your shahada out of fear.
- Keep up your prayers and dhikr; Shaytan wants you to quit them.
- If the thoughts are constant and distressing, they may be OCD, which is treatable. See Mental health in Islam.
Related: Are you punished for thinking about a sin? and Does Allah hate me?
Ask a mufti about your own case. This answer explains the general ruling. When the details of your situation matter, as they do here, ask a qualified mufti and give them the full facts. Where to ask a scholar.
The evidence
Quran, Surah Al-Baqara 2:286
لَا يُكَلِّفُ ٱللَّهُ نَفْسًا إِلَّا وُسْعَهَا ۚ لَهَا مَا كَسَبَتْ وَعَلَيْهَا مَا ٱكْتَسَبَتْ ۗ رَبَّنَا لَا تُؤَاخِذْنَآ إِن نَّسِينَآ أَوْ أَخْطَأْنَا ۚ رَبَّنَا وَلَا تَحْمِلْ عَلَيْنَآ إِصْرًۭا كَمَا حَمَلْتَهُۥ عَلَى ٱلَّذِينَ مِن قَبْلِنَا ۚ رَبَّنَا وَلَا تُحَمِّلْنَا مَا لَا طَاقَةَ لَنَا بِهِۦ ۖ وَٱعْفُ عَنَّا وَٱغْفِرْ لَنَا وَٱرْحَمْنَآ ۚ أَنتَ مَوْلَىٰنَا فَٱنصُرْنَا عَلَى ٱلْقَوْمِ ٱلْكَٰفِرِينَ ﴿٢٨٦﴾
Allah does not charge a soul except [with that within] its capacity. It will have [the consequence of] what [good] it has gained, and it will bear [the consequence of] what [evil] it has earned. "Our Lord, do not impose blame upon us if we have forgotten or erred. Our Lord, and lay not upon us a burden like that which You laid upon those before us. Our Lord, and burden us not with that which we have no ability to bear. And pardon us; and forgive us; and have mercy upon us. You are our protector, so give us victory over the disbelieving people."
No one is blamed for what is beyond their control.
Sahih Muslim 132
Sahih... وقد وجدتموه قالوا نعم قال ذاك صريح الإيمان ...
"Have you really found that? They said yes. He said: That is clear faith."
Hating evil thoughts is a sign of faith.
Sahih al-Bukhari 3276
Sahih... من خلق ربك فإذا بلغه فليستعذ بالله ولينته ...
"Who created your Lord? When it reaches that, let him seek refuge in Allah and stop."
The cure for such whispers is to seek refuge and stop.
Sahih al-Bukhari 5269
Sahih... إن الله تجاوز عن أمتي ما حدثت به أنفسها ما لم تعمل أو تتكلم ...
"Allah has overlooked for my ummah what their selves whisper, as long as they do not act on it or speak it."
Passing thoughts are not counted as sins.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Bab al-Murtadd (chapter on apostasy). Explains that apostasy requires a deliberate choice, and that waswasa does not make a person a disbeliever.
- al-Fatawa al-Hindiyya, Kitab al-Siyar, chapter on the rulings of apostates. Distinguishes words said by mistake or under compulsion from deliberate kufr.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.