The Messenger of Allah ﷺ said, "Satan comes to one of you and asks, 'Who created such and such? Who created such and such?' until he says, 'Who created your Lord?' When it reaches that point, let him seek refuge in Allah and stop."In another narration, "Let him say, 'I believe in Allah and His Messenger.'"
قال رسول الله ﷺ: يأتي الشيطان أحدكم فيقول: من خلق كذا؟ من خلق كذا؟ حتى يقول: من خلق ربك؟ فإذا بلغه فليستعذ بالله ولينته. وفي رواية: فليقل: آمنت بالله ورسوله.
Bukhari related it in the Book of the Beginning of Creation (3276), and Muslim in the Book of Faith (134), both from the hadith of Layth bin Saad, who said, Aqeel bin Khalid narrated to me, from Ibn Shihab, from Urwa bin Zubayr, from Abu Hurairah, and he narrated it. The wording is Bukhari's. The second narration is found in Muslim (134: 212–213) via the route of Hisham bin Urwa, from his father, from Abu Hurairah.Ibn Abbas used to instruct that in this situation one should recite "He is the First and the Last, the Manifest and the Hidden, and He has knowledge of all things" [Hadid 57:3]. Abu Dawud related this (5110) from Abbas bin Abdul-Azim, who said, Nadr bin Muhammad narrated to us, who said, Ikrima bin Ammar narrated to us, who said, and Abu Zumayl narrated to us, who said, I asked Ibn Abbas, saying, "What is this thing I find in my chest?"He said, "What is it?"I said, "By Allah, I will not speak of it."He said, then he said to me, "Is it something of doubt?"He said, and he laughed, and said, "No one has been saved from that."He said, until Allah revealed "So if you are in doubt about what We have revealed to you, then ask those who have been reading the Scripture before you" [Yunus 10:94], the verse.He said, then he said to me, "If you find something within yourself, then say, "He is the First and the Last, the Manifest and the Hidden, and He has knowledge of all things"."Its chain of transmission is hasan because of Ikrima bin Ammar and Abu Zumayl, for both of them are narrators whose hadith is graded hasan, and it is mawquf.