Mishkat al-Masabih 987
وَعَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: إِنَّ عِفْرِيتًا مِنَ الْجِنِّ تَفَلَّتَ الْبَارِحَةَ لِيَقْطَعَ عَلَيَّ صَلَاتِي فَأَمْكَنَنِي اللَّهُ مِنْهُ فَأَخَذْتُهُ فَأَرَدْتُ أَنْ أَرْبِطَهُ عَلَى سَارِيَةٍ مِنْ سَوَارِي الْمَسْجِدِ حَتَّى تَنْظُرُوا إِلَيْهِ كُلُّكُمْ فَذَكَرْتُ دَعْوَةَ أَخِي سُلَيْمَانَ: (رَبِّ هَبْ لِي مُلْكًا لَا يَنْبَغِي لِأَحَدٍ مِنْ بَعْدِي) فَرَدَدْتُهُ خَاسِئًا
From Abu Hurayrah, may Allah be pleased with him, who said: The Messenger of Allah ﷺ said: "An ʿifrit of the jinn broke loose last night to interrupt my prayer, but Allah gave me power over him. I seized him and wanted to tie him to one of the pillars of the mosque so that all of you could look at him. Then I remembered the supplication of my brother Sulayman: 'My Lord, grant me a kingdom such as will not belong to anyone after me', so I sent him back humiliated."