While some people were offering Fajr prayer at Quba mosque, someone came to them and said, "Qur'anic literature" has been revealed to Messenger of Allah ﷺ tonight, and he has been ordered to face the Kaʿba (of Mecca) so you too, should turn your faces towards it. Their faces were then towards Sham (Jerusalem), so they turned towards the Qibla (i.e. Kaʿba of Mecca).
بَيْنَمَا النَّاسُ فِي صَلاَةِ الصُّبْحِ بِقُبَاءٍ إِذْ جَاءَهُمْ آتٍ فَقَالَ إِنَّ رَسُولَ اللَّهِ ﷺ قَدْ أُنْزِلَ عَلَيْهِ اللَّيْلَةَ وَقَدْ أُمِرَ أَنْ يَسْتَقْبِلَ الْكَعْبَةَ فَاسْتَقْبِلُوهَا وَكَانَتْ وُجُوهُهُمْ إِلَى الشَّأْمِ فَاسْتَدَارُوا إِلَى الْقِبْلَةِ