It is narrated from Sayyiduna Abu Ayyub al-Ansari (may Allah be pleased with him) that he had a small storeroom, and a ghoul (a jinn) used to come and enter it. He complained about it to the Prophet (peace and blessings be upon him), and he (peace and blessings be upon him) said: "When you see it, say: Bismillah (In the name of Allah), answer the Messenger of Allah (peace and blessings be upon him)." Then it came, and he said this to it and seized it. It said: I will not come back. So he let it go. Then he came to the Prophet (peace and blessings be upon him), and the Prophet (peace and blessings be upon him) said to him: "What did your captive do?" He said: I seized it, and it said: I will not come back, so I let it go. He (peace and blessings be upon him) said: "It will certainly come back." So I seized it two or three times, and each time it would say: I will not come back. And the Prophet (peace and blessings be upon him) would come and ask: "What did your captive do?" He would say: I seized it, and it said: I will not come back. He (peace and blessings be upon him) would say: "It will certainly come back." Then I seized it again, and it said: Let me go, and I will teach you something which, if you say it, nothing will come near you: it is Ayat al-Kursi. So I came to the Prophet (peace and blessings be upon him) and told him, and he (peace and blessings be upon him) said: "It spoke the truth, though it is a great liar."
Hadith Referenceالمعجم الكبير للطبراني / باب الخاء / 3996