While the people were at Quba performing the dawn prayer, someone came to them and said, "The Messenger of Allah ﷺ received revelation last night, and he has been commanded to face the Kaabah, so face it." Their faces had been toward Sham, so they turned around toward the Kaabah.
أخبرنا قتيبة عن مالك عن عبد الله بن دينار
بينما الناس بقباء في صلاة الصبح جاءهم آت فقال إن رسول الله ﷺ قد أنزل عليه الليلة وقد أمر أن يستقبل الكعبة فاستقبلوها وكانت وجوههم إلى الشام فاستداروا إلى الكعبة
Bukhari transmitted it in the Book of Prayer, chapter on what has been said about the qibla and on the view that one need not repeat the prayer if, out of forgetfulness, one prayed facing a direction other than the qibla, hadith no. 403, and Muslim in the Book of Mosques, chapter on the change of the qibla from Jerusalem to the Kaaba, hadith no. 526, both from the hadith of Malik through this chain, and it is found in Muwatta (Yahya), 1/195.