Abdullah bin Abbas reported,

A man came to the Prophet ﷺ and said, "Messenger of Allah, one of us finds within himself," alluding to something, "such thoughts that he would rather be reduced to a piece of charcoal than utter them."The Prophet ﷺ said, "Allah is the Greatest! Allah is the Greatest! Allah is the Greatest! Praise be to Allah who reduced his scheme to mere whisperings."

Azami 219

Sahih

عن ابن عباس قال

جاء رجل إلى النبي ﷺ فقال: يا رسول إن أحدنا يجد في نفسه- يعرض بالشيء- لأن يكون حممة أحب إليه أن يتكلم به. فقال: الله أكبر الله أكبر الله أكبر! الحمد لله الذي رد كيده إلى الوسوسة.

الأعظمي 219صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Faith
Chapter
Faith in Allah عز وجل
Section
Waswasa is from sincere faith
Numbering
Jami al-Kamil 219 (2nd edition)
Azami 219