The Messenger of Allah ﷺ said, "When one of you goes to relieve himself, he should neither face the qiblah nor turn his back to it. Face east or west instead."
قال رسول الله ﷺ: إذا أتى أحدكم الغائط؛ فلا يستقبل القبلة ولا يولها ظهره؛ شرقوا أو غربوا.
Bukhari narrated it in the chapter on wudu (144) and Muslim in the chapter on purification (264), both through the route of Zuhri, from Ata bin Yazid Laythi, from Abu Ayub Ansari.Abu Ayub said, "We came to Syria and found that latrines had been built facing the qibla, so we would turn away from it and seek Allah's forgiveness."In a version reported by Malik in the chapter on the qibla (1), Abu Ayub Ansari, while he was in Egypt, said, "By Allah, I do not know what to do about these latrines, when the Messenger of Allah ﷺ said, 'When any of you goes to relieve himself, for defecation or urination, he should not face the qibla nor turn his back to it with his private parts.'"There is no contradiction between the two accounts, since it is possible that this happened to him in both countries.The word karayis is spelled with two ya's, and it means latrines, the singular of which is kiryas. This refers to a structure that rises above ground level with a channel running down into the earth. If it is at ground level, it is not called a kiryas. It was given this name because of the filth that clings to it and accumulates, like the piling up of dung.Some linguists render it with a nun instead, as kirnas.