Narrated Abu Huraira:
The Prophet said, “A strong demon from the Jinns came to me yesterday suddenly, so as to spoil my prayer, but Allah enabled me to overpower him, and so I caught him and intended to tie him to one of the pillars of the Mosque so that all of you might see him, but I remembered the invocation of my brother Solomon: ‘And grant me a kingdom such as shall not belong to any other after me.’ (38.35) so
I let him go cursed.”
Sahih Bukhari, Volume 4, Book55, Number 634