Maliks Muwatta Book 014, Hadith Number 001.

Section : The Prohibition against Relieving Oneself Facing the Qibla.

Yahya related to me from Malik from Ishaq ibn Abdullah ibn Abi Talha that Rafiibn Ishaq, a mawla of the family of ash-Shifa who was known as the mawla of Abu Talha, heard Abu Ayyub al-Ansari, one of the companions of the Messenger of Allah, may Allah bless him and grant him peace, say, while he was in Egypt, "By Allah! I don't know how to deal with these lavatories." The Messenger of Allah, may Allah bless him and grant him peace, said, "When you go to defecate or urinate, do not expose your genitals towards the qibla, and do not put your back to it."