It is narrated from Abu Ayyub Ansari (may Allah be pleased with him) that the Prophet (peace be upon him) forbade us from facing the Qiblah when relieving ourselves, but instructed us to face either the east or the west. Abu Ayyub Ansari (may Allah be pleased with him) says: When we went to Syria, we saw that the places built for urination were facing the Qiblah, so we returned seeking forgiveness from Allah.
Hadith Referenceمسند الإمام الشافعي / كتاب الطهارة / 35
Hadith Takhrijأخرجه البخاري: الصلاة، باب قبلة أهل المدينة وأهل الشام والمشرق (394)، ومسلم: الطهارة، باب الاستطابة (264).