Sayyiduna Abu Hurairah (may Allah be pleased with him) narrates this statement of the Prophet (peace and blessings of Allah be upon him): "Indeed, Allah the Exalted has pardoned my Ummah for what thoughts occur in their minds, as long as they do not speak about them or act upon them."
Hadith Referenceصحیح ابن حبان / كتاب الأيمان / 4335
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيصحيح: ق - انظر ما قبله.فضيلة الشيخ العلّامة شُعيب الأرناؤوطإسناده قوي