The Messenger of Allah ﷺ used to pray on his mount, facing whichever direction it was heading, while traveling from Mecca to Medina. Concerning this, the verse was revealed, "So wherever you turn, there is the face of Allah" [Baqarah 2:115].
كان رسول الله ﷺ يصلي وهو مقبل من مكة إلى المدينة على راحلته حيث كان وجهه قال: وفيه نزلت: {فأينما تولوا فثم وجه الله}
Muslim narrated it in the Book of the Prayer of Travelers (34:700) from Ubaydullah bin Umar Qawariri, who said, Yahya bin Saeed related to us, from Abdul-Malik bin Abu Sulayman, who said, Saeed bin Jubayr related to us, from Ibn Umar, who said, and then he mentioned it.Similar in meaning is what has been narrated from Amir bin Rabia, from his father, though it contains Asim bin Ubaydullah, who is daif. See its documentation in the Book of Prayer, chapter on the obligation of facing the qibla.It has been narrated from Qatada that he said regarding this verse, "To Allah belong the east and the west. So wherever you turn, there is the face of Allah. Indeed, Allah is all-encompassing, all-knowing" [Baqarah 2:115], that it is abrogated, its abrogation coming through His saying, "So turn your face toward Masjid al-Haram" [Baqarah 2:150], meaning, toward it directly.