Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:2:115

And to Allah belongs the east and the west. So wherever you ˹might˺ turn, there is the Face of Allah. Indeed, Allah is all-Encompassing and Knowing.  

The following was revealed either when the Jews criticised the change of the direction of prayer ˹qibla˺, or concerning the supererogatory prayers on animal-back during journeys, which one may pray in any direction: To God belong the East and the West, that is, the entire earth, because these two ˹directions˺ represent both sides of it ˹the earth˺; whithersoever you turn, your faces in prayer by His command, there is the Face of God, the direction of prayer with which He is pleased. Lo! God is Embracing, His bounty embracing all things, Knowing, how to manage His creation.
القرآن:٢:١١٥

وَلِلَّهِ الْمَشْرِقُ وَالْمَغْرِبُ ۚ فَأَيْنَمَا تُوَلُّوا فَثَمَّ وَجْهُ اللَّهِ ۚ إِنَّ اللَّهَ وَاسِعٌ عَلِيمٌ  

ونزل لما طعن اليهود في نسخ القبلة أو في صلاة النافلة على الراحلة في السفر حيثما توجهت {ولله المشرق والمغرب} أي الأرض كلها لأنهما ناحيتها {فأينما تولوا} وجوهكم في الصلاة بأمره {فثمَّ} هناك {وجه الله} قبلته التي رضيها {إن الله واسع} يسع فضله كل شئ {عليم} بتدبير خلقه.

See similar narrations below:

Collected by Bayhaqī
bayhaqi:2201Muḥammad b. ʿAbdullāh al-Ḥāfiẓ > Abū al-ʿAbbās Muḥammad b. Yaʿqūb > ʿAbbās b. Muḥammad al-Dūrī > Muḥammad b. ʿUbayd al-Ṭanāfisī > ʿAbd al-Malik b. Abū Sulaymān > Saʿīd b. Jubayr

[Machine] The Prophet ﷺ used to do this and then recited this verse, "To Allah belongs the east and the west. So wherever you turn, there is the face of Allah. Indeed, Allah is all-encompassing and knowing." [Al-Baqarah 2:115] Then he said, "This verse was revealed regarding this."  

البيهقي:٢٢٠١أَخْبَرَنَا مُحَمَّدُ بْنُ عَبْدِ اللهِ الْحَافِظُ أنبأ أَبُو الْعَبَّاسِ مُحَمَّدُ بْنُ يَعْقُوبَ أنبأ عَبَّاسُ بْنُ مُحَمَّدٍ الدُّورِيُّ ثنا مُحَمَّدُ بْنُ عُبَيْدٍ الطَّنَافِسِيُّ ثنا عَبْدُ الْمَلِكِ بْنُ أَبِي سُلَيْمَانَ عَنْ سَعِيدِ بْنِ جُبَيْرٍ قَالَ كَانَ ابْنُ عُمَرَ يُصَلِّي عَلَى رَاحِلَتِهِ يُومِي إِيمَاءً أَيْنَمَا تَوَجَّهَتْ بِوَجْهِهِ تَطَوُّعًا قَالَ

وَكَانَ النَّبِيُّ ﷺ يَفْعَلُ ذَلِكَ ثُمَّ قَرَأَ هَذِهِ الْآيَةَ {وَلِلَّهِ الْمَشْرِقُ وَالْمَغْرِبُ فَأَيْنَمَا تُوَلُّوا فَثَمَّ وَجْهُ اللهِ إِنَّ اللهَ وَاسِعٌ عَلِيمٌ} [البقرة 115] ثُمَّ قَالَ فِي هَذَا أُنْزِلَتْ هَذِهِ الْآيَةُ