It is narrated from Sayyiduna Ibn Umar (may Allah be pleased with them both) that once the people were offering the Fajr prayer in the mosque of Quba when a man came to them and said: "Qur'an has been revealed to the Messenger of Allah (peace and blessings be upon him), and he has been commanded to face the Ka'bah in prayer, so face it." Their faces were toward al-Sham (Syria), so they turned (while still in prayer) toward the Ka'bah.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 2239