Sayyiduna Bara’ (may Allah be pleased with him) narrates: When the Prophet (peace and blessings of Allah be upon him) arrived in Madinah Munawwarah, he prayed facing Bayt al-Maqdis for sixteen months, or perhaps seventeen months. He wished that his direction be changed towards the Ka‘bah, so Allah Almighty revealed this verse: “We have certainly seen the turning of your face towards the heaven, so We will surely turn you to a qiblah with which you will be pleased. So turn your face towards al-Masjid al-Haram.” Then a man passed by some of the Ansar who were in the state of bowing, and this man testified and said that he had prayed with the Prophet (peace and blessings of Allah be upon him), and the Prophet’s direction had been turned towards the Ka‘bah. Imam Ibn Hibban (may Allah have mercy on him) says: After the Prophet (peace and blessings of Allah be upon him) arrived in Madinah Munawwarah, the Muslims prayed facing Bayt al-Maqdis for seventeen months and three days, because the Prophet (peace and blessings of Allah be upon him) arrived in Madinah Munawwarah on Monday, the 12th of Rabi‘ al-Awwal, and Allah Almighty commanded the change of direction towards the Ka‘bah on Tuesday, the 15th of Sha‘ban al-Mu‘azzam. Thus, what we have mentioned is considered correct.
Hadith Referenceصحیح ابن حبان / كتاب الصلاة / 1716
Hadith Gradingفضيلة الشيخ الإمام محمد ناصر الدين الألبانيصحيح - «صفة الصلاة»: ق.فضيلة الشيخ العلّامة شُعيب الأرناؤوطإسناده صحيح على شرطهما، أبو إسحاق: هو عمرو بن عبد الله.