Sahih al-Bukhari 1100
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
حَدَّثَنَا أَحْمَدُ بْنُ سَعِيدٍ، قَالَ حَدَّثَنَا حَبَّانُ، قَالَ حَدَّثَنَا هَمَّامٌ، قَالَ حَدَّثَنَا أَنَسُ بْنُ سِيرِينَ، قَالَ اسْتَقْبَلْنَا أَنَسًا حِينَ قَدِمَ مِنَ الشَّأْمِ، فَلَقِينَاهُ بِعَيْنِ التَّمْرِ، فَرَأَيْتُهُ يُصَلِّي عَلَى حِمَارٍ وَوَجْهُهُ مِنْ ذَا الْجَانِبِ، يَعْنِي عَنْ يَسَارِ الْقِبْلَةِ. فَقُلْتُ رَأَيْتُكَ تُصَلِّي لِغَيْرِ الْقِبْلَةِ. فَقَالَ لَوْلاَ أَنِّي رَأَيْتُ رَسُولَ اللَّهِ صلى الله عليه وسلم فَعَلَهُ لَمْ أَفْعَلْهُ. رَوَاهُ ابْنُ طَهْمَانَ عَنْ حَجَّاجٍ عَنْ أَنَسِ بْنِ سِيرِينَ عَنْ أَنَسٍ ـ رضى الله عنه ـ عَنِ النَّبِيِّ صلى الله عليه وسلم.
Narrated Anas bin Seereen:
We went to receive Anas bin Malik when he returned from Sham and met him at a place called 'Ainat- Tamr. I saw him praying riding the donkey, with his face to this direction, i.e. to the left of the Qibla. I said to him, "I have seen you offering the prayer in a direction other than that of the Qibla." He replied, "If I had not seen Allah's Messenger (ﷺ) doing it, I would not have done it."
Full reference and source
Sahih al-Bukhari 1100 In-book : Book 18, Hadith 20 USC-MSA web (English) : Vol. 2, Book 20, Hadith 204 (deprecated)
View source on Sunnah.com (opens in a new tab)