Abdullah bin Umar (may Allah be pleased with them both) said that people used to say: "When you sit to relieve yourself, do not face the qiblah or Bayt al-Maqdis." Abdullah bin Umar (may Allah be pleased with them both) said: I climbed onto the roof of our house and saw the Messenger of Allah (peace and blessings be upon him) on two bricks, and he (peace and blessings be upon him) was facing Bayt al-Maqdis while relieving himself.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 435
Sayyiduna Abdullah bin Umar (may Allah be pleased with them both) said: One day I climbed onto the roof of our house and saw the Messenger of Allah (peace and blessings be upon him) sitting on two bricks to relieve himself, and he (peace and blessings be upon him) had his face towards Syria and his back towards the qiblah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 437
Marwan al-Asfar said: I saw Ibn Umar (may Allah be pleased with them both) make his mount kneel facing the qiblah, then he sat down and urinated. I said: O Abu Abd al-Rahman! Has this not been forbidden? He said: Certainly! It has been forbidden in open space, but when there is something between you and the qiblah that screens you (that is, there is some barrier), then there is no harm in it.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 438
It is narrated from Sayyiduna Jabir (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) used to forbid us "to face the qiblah or turn our backs to it with our private parts when we pour out water (that is, urinate)." Then I saw him (peace and blessings be upon him) a year before his death urinating while facing the qiblah.
(b) In the Sunan of Abu Dawud the wording is: I saw him a year before his soul was taken, sitting facing the qiblah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 440
It is narrated from Khalid bin Abi al-Salt (may Allah have mercy on him) that he said: I was with Umar bin Abd al-Aziz (may Allah have mercy on him) during his caliphate, and Irak bin Malik (may Allah have mercy on him) was also with him. Umar bin Abd al-Aziz (may Allah have mercy on him) said: "For such and such a length of time I have neither faced the qiblah nor turned my back to it when urinating or relieving myself." Irak (may Allah have mercy on him) said: Sayyidah Aishah (may Allah be pleased with her) narrated to me that when what people were saying about this reached the Messenger of Allah (peace and blessings be upon him), he (peace and blessings be upon him) ordered that his toilet seat be turned to face the qiblah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 441
Sayyiduna Ibn Umar (may Allah be pleased with them both) narrated: I entered the house of Sayyidah Hafsah (may Allah be pleased with her), and my glance happened to fall, and I saw the toilet of the Messenger of Allah (peace and blessings be upon him) facing the qiblah.
(b) Sayyiduna Abu Hurayrah (may Allah be pleased with him) said: "When one of you comes to relieve himself, he should neither face the qiblah nor turn his back to it."
(c) Al-Sha'bi (may Allah have mercy on him) said: Both spoke the truth. The statement of Abu Hurayrah (may Allah be pleased with him) concerns the open desert, for Allah has servants, angels and jinn, who pray there, so one should neither face them nor turn one's back to them when relieving oneself or urinating in the desert; as for their toilets, they are houses in which there is no qiblah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الطهارة / 442