Question
What is the ruling on seeking refuge when entering the lavatory?
Answer
I say, and with God's success: It is recommended to seek refuge with Allah the Almighty from the devil when entering the restroom; because the devil is present in these places, by saying: "O Allah, I seek refuge with You from the evil and the evil ones"; as narrated by Anas (may Allah be pleased with him) who said: "When the Prophet (peace be upon him) entered the restroom, he would say: O Allah, I seek refuge with You from the evil and the evil ones," in Sahih al-Bukhari 1/66, and the wording is his. And in Sahih Muslim 1/283.
And from Al-Dhahak who said: "Whenever Hudhayfah entered the restroom, he would say: 'I seek refuge with Allah from the filthy and the impure, the evil and the evil one, from the accursed devil'" in the Musannaf of Ibn Abi Shaybah, 6/114. And from Abu Umamah (may Allah be pleased with him) in a raised narration: "None of you should be unable when entering his place of need to say: 'O Allah, I seek refuge with You from the filthy and the impure, the evil and the evil one, the accursed devil'" in Sunan Ibn Majah 1/109.
And from Zayd ibn Arqam (may Allah be pleased with him) in a raised narration: "Indeed, these restrooms - which are places for relieving oneself - are attended by devils, so when one of you enters the restroom, let him say: 'I seek refuge with Allah from the evil and the evil ones'" in Sunan Abu Dawood 1/49, and in Al-Mustadrak 1/298, and it was authenticated, and in Sunan Ibn Majah 1/108. See: Bada'i al-Sana'i, 5/126, and Tabyin al-Haqaiq, 1/166, and Fath al-Qadeer, 1/419, and Al-Tawdeeh Sharh Muqaddimah Abi al-Layth, and Allah knows best.