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.
bukhari:4493Mūsá b. Ismāʿīl > ʿAbd al-ʿAzīz b. Muslim > ʿAbdullāh b. Dīnār > Ibn ʿUmar

While some people were at Quba (offering) morning prayer, a man came to them and said, "Last night Qur'anic Verses have been revealed whereby the Prophet ﷺ has been ordered to face the Kaʿba (at Mecca), so you too should face it." So they, keeping their postures, turned towards the Kaʿba. Formerly the people were facing Sham (Jerusalem) (Allah said):-- "And from whence-so-ever you start forth (for prayers), turn your face in the direction of the Sacred Mosque of Mecca (Al-Masjid-ul-Haram), and whence-so-ever you are, turn your face towards it (when you pray)" (2.150)  

البخاري:٤٤٩٣حَدَّثَنَا مُوسَى بْنُ إِسْمَاعِيلَ حَدَّثَنَا عَبْدُ الْعَزِيزِ بْنُ مُسْلِمٍ حَدَّثَنَا عَبْدُ اللَّهِ بْنُ دِينَارٍ قَالَ سَمِعْتُ ابْنَ عُمَرَ ؓ يَقُولُ بَيْنَا النَّاسُ فِي الصُّبْحِ بِقُبَاءٍ إِذْ جَاءَهُمْ رَجُلٌ فَقَالَ أُنْزِلَ اللَّيْلَةَ قُرْآنٌ فَأُمِرَ

أَنْ يَسْتَقْبِلَ الْكَعْبَةَ فَاسْتَقْبِلُوهَا وَاسْتَدَارُوا كَهَيْئَتِهِمْ فَتَوَجَّهُوا إِلَى الْكَعْبَةِ وَكَانَ وَجْهُ النَّاسِ إِلَى الشَّأْمِ  


See similar narrations below:

Collected by Bukhārī
bukhari:4490Khālid b. Makhlad > Sulaymān > ʿAbdullāh b. Dīnār > Ibn

While some people were offering morning prayer at Quba' a man came to them and said, "A Qur'anic Order has been revealed to Messenger of Allah ﷺ tonight that he should face the Kaʿba at Mecca (in prayer), so you too should turn your faces towards it." At that moment their faces were towards Sham (i.e. Jerusalem) (and on hearing that) they turned towards the Kaʿba (at Mecca).  

البخاري:٤٤٩٠حَدَّثَنَا خَالِدُ بْنُ مَخْلَدٍ حَدَّثَنَا سُلَيْمَانُ حَدَّثَنِي عَبْدُ اللَّهِ بْنُ دِينَارٍ عَنِ ابْنِ عُمَرَ ؓ بَيْنَمَا النَّاسُ فِي الصُّبْحِ بِقُبَاءٍ جَاءَهُمْ رَجُلٌ فَقَالَ

إِنَّ رَسُولَ اللَّهِ ﷺ قَدْ أُنْزِلَ عَلَيْهِ اللَّيْلَةَ قُرْآنٌ وَأُمِرَ أَنْ يَسْتَقْبِلَ الْكَعْبَةَ أَلاَ فَاسْتَقْبِلُوهَا وَكَانَ وَجْهُ النَّاسِ إِلَى الشَّأْمِ فَاسْتَدَارُوا بِوُجُوهِهِمْ إِلَى الْكَعْبَةِ