The Messenger of Allah ﷺ used to pray facing Bayt al-Maqdis, and then this was revealed, "We have certainly seen you turning your face about toward the heaven, so We shall surely turn you toward a qibla that will please you. So turn your face toward Masjid al-Haram, and wherever you may be, turn your faces toward it. Those who have been given the Scripture know well that it is the truth from their Lord, and Allah is not unaware of what they do" [Baqarah 2:144].A man from the tribe of Banu Salama passed by while they were bowing in the Fajr prayer, having already completed one rakat, and he called out, "Take note, the qibla has been changed!"So they turned, just as they were, toward the new qibla.
أن رسول الله ﷺ كان يصلي نحو بيت المقدس فنزلت: {قد نرى تقلب وجهك في السماء فلنولينك قبلة ترضها فول وجهك شطر المسجد الحرام وحيث ما كنتم فولوا وجوهكم شطره وإن الذين أوتوا الكتاب ليعلمون أنه الحق من ربهم وما الله بغفل عما يعملون} فمر رجل من بني سلمة، وهم ركوع في صلاة الفجر، وقد صلوا ركعة فنادى: ألا إن القبلة قد حولت، فمالوا كما هو نحو القبلة.
Muslim narrated it in the Book of Mosques (527) from Abu Bakr bin Abu Shayba, who said, Affan told us, Hammad bin Salama told us, from Thabit, from Anas, and he mentioned it. Bukhari narrated it (4489) with his chain of transmission from Anas, who said, "No one remains alive who prayed toward the two prayer directions except me." And the words of the Most High, "And thus We have made you a just community that you may be witnesses over the people, and the Messenger may be a witness over you" [Baqarah 2:143]