Hadith 3.1
Purification
Abu Ayyub al-Ansari reported God’s messenger as saying, "When you go to the toilet neither face nor turn your back to the qibla [<i>Ka'ba</i> in Mecca], but turn towards the east or the west.” (Bukhari and Muslim.) The <i>shaikh</i> and <i>imam</i> Muhyi as-Sunna said that this tradition applies to the desert, but that in a built-up area it does not matter, on account of what is transmitted from ‘Abdallah b. ‘Umar who said, "I went up to the roof of Hafsa’s house for some purpose and saw God's messenger relieving himself facing Syria, with his back to the <i>qibla</i>.” (Bukhari and Muslim.)
عَنْ أَبِي أَيُّوبَ الْأَنْصَارِيِّ قَالَ: قَالَ رَسُولُ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «إِذَا أَتَيْتُمُ الْغَائِطَ فَلَا تَسْتَقْبِلُوا الْقِبْلَةَ وَلَا تَسْتَدْبِرُوهَا وَلَكِنْ شَرِّقُوا أَوْ غَرِّبُوا» قَالَ الشَّيْخ الإِمَام محيي السّنة : هَذَا الْحَدِيثُ فِي الصَّحْرَاءِ وَأَمَّا فِي الْبُنْيَانِ فَلَا بَأْس لما رُوِيَ: عَن عبد الله بن عمر قَالَ: ارْتَقَيْتُ فَوْقَ بَيْتِ حَفْصَةَ لِبَعْضِ حَاجَتِي فَرَأَيْتُ رَسُولَ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ يقْضِي حَاجته مستدبر الْقبْلَة مُسْتَقْبل الشَّام
Hadith gradings, numbering and translations can differ between editions. For legal rulings or detailed interpretation, consult qualified scholarship and the referenced edition.