Abu Hurairah reported,

The Prophet ﷺ said, "An ifrit from the jinn came at me suddenly last night," or words to that effect, "trying to interrupt my prayer. But Allah gave me power over him, and I intended to tie him to one of the pillars of the mosque so that you would all see him in the morning. Then I remembered the words of my brother Sulayman, 'My Lord, grant me a kingdom such as shall not belong to anyone after me' [Sad 38:35]."Rawh added, "So he sent him back humiliated."

Bukhari 4808

Sahih

حدثنا إسحاق بن إبراهيم حدثنا روح ومحمد بن جعفر عن شعبة عن محمد بن زياد

عن أبي هريرة

عن النبي ﷺ قال إن عفريتا من الجن تفلت علي البارحة أو كلمة نحوها ليقطع علي الصلاة فأمكنني الله منه وأردت أن أربطه إلى سارية من سواري المسجد حتى تصبحوا وتنظروا إليه كلكم فذكرت قول أخي سليمان رب {هب لي ملكا لا ينبغي لأحد من بعدي} قال روح فرده خاسئا

البخاري 4808صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Tafsir
Chapter
His saying, "Grant me a kingdom such as shall not belong to anyone after me. Indeed, You are the Bestower"
Numbering
Darussalam 4808
Bukhari 4808