The Messenger of Allah ﷺ said, "An ifrit from the jinn came at me last night trying to break my prayer, but Allah gave me power over him and I seized him by the throat. I was about to tie him to one of the pillars of the mosque so that you could all look at him in the morning, but then I remembered the words of my brother Sulayman, 'He said, My Lord, forgive me and grant me a kingdom such as shall not belong to anyone after me' [Sad 38:35], so Allah turned him back humiliated."
قال رسول الله ﷺ: إن عفريتا من الجن جعل يفتك علي البارحة ليقطع علي الصلاة، وإن الله أمكنني منه فذعته، فلقد هممت أن أربطه إلى جنب سارية من سواري المسجد حتى تصبحوا تنظرون إليه أجمعون- أو كلكم- ثم ذكرت قول أخي سليمان: {قال رب اغفر لي وهب لي ملكا لا ينبغي لأحد من بعدي} فرده الله خاسئا.
Bukhari narrated it in the tafsir (4808), and Muslim in the mosques (541), both through the route of Shubah, who said, "Muhammad bin Ziyad narrated to us, saying, 'I heard Abu Hurairah say,'" and then he related it. The wording given here is that of Muslim.His saying, "an ifrit," the ifrit is one who is powerful, wicked, and evil.His saying, "yaftik," al-fatk means seizing someone through negligence and deception.His saying, "fa-dhaattuhu," dhaata means he strangled him.