It is narrated from Sayyiduna Abdullah bin Umar (may Allah be pleased with them) that the people were performing the Fajr prayer in Quba when a person came and said: Revelation has come to Allah’s Messenger (peace and blessings be upon him) tonight, and we have been commanded to pray facing the Ka’bah, so turn your faces towards the Ka’bah. Their faces were towards Shaam, so they turned towards the Ka’bah.
Hadith Referenceالسنن المأثورة / ما جاء في الجمع بين الصلاتين في المطر / 35
Hadith Takhrijصحیح بخاری، التفسیر باب الذین اتیناہم الکتاب یعرفونہ، رقم: 4491؛ صحیح مسلم، المساجد ومواضع الصلاة، باب تحویل القبلة من القدس الی الکعبة، رقم: 526