Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
malik:14-8Mālik > Yaḥyá b. Saʿīd > Saʿīd b. al-Musayyab

Yahya related to me from Malik from Yahya ibn Said that Said ibn al-Musayyab said, "The Messenger of Allah ﷺ prayed towards the Baytal-Maqdis for sixteen months after arriving in Madina. Then the qibla was moved, two months before the battle of Badr. "  

مالك:١٤-٨وَحَدَّثَنِي عَنْ مَالِكٍ عَنْ يَحْيَى بْنِ سَعِيدٍ عَنْ سَعِيدِ بْنِ الْمُسَيَّبِ

أَنَّهُ قَالَ صَلَّى رَسُولُ اللَّهِ ﷺ بَعْدَ أَنْ قَدِمَ الْمَدِينَةَ سِتَّةَ عَشَرَ شَهْرًا نَحْوَ بَيْتِ الْمَقْدِسِ ثُمَّ حُوِّلَتِ الْقِبْلَةُ قَبْلَ بَدْرٍ بِشَهْرَيْنِ  


See similar narrations below:

Collected by Bayhaqī, Suyūṭī
bayhaqi:2194Abū al-Ḥasan Muḥammad b. al-Ḥusayn al-Qaṭṭān> Abū Sahl b. Ziyād al-Qaṭṭān > Aḥmad b. ʿAbd al-Jabbār > Muḥammad b. al-Fuḍayl > Yaḥyá b. Saʿīd > Saʿīd b. al-Musayyib > Saʿd

[Machine] I heard Saad say that the Messenger of Allah ﷺ prayed after he arrived in Medina for about sixteen months towards the direction of Beit Al-Maqdis (Jerusalem). Then after that, the direction was changed towards the Sacred Mosque (in Mecca) two months before the Battle of Badr, like this.  

البيهقي:٢١٩٤أَخْبَرَنَا أَبُو الْحَسَنِ مُحَمَّدُ بْنُ الْحُسَيْنِ الْقَطَّانُ بِبَغْدَادَ ثنا أَبُو سَهْلِ بْنُ زِيَادٍ الْقَطَّانُ ثنا أَحْمَدُ بْنُ عَبْدِ الْجَبَّارِ ثنا مُحَمَّدُ بْنُ الْفُضَيْلِ ثنا يَحْيَى بْنُ سَعِيدٍ عَنْ سَعِيدِ بْنِ الْمُسَيِّبِ قَالَ

سَمِعْتُ سَعْدًا يَقُولُ صَلَّى رَسُولُ اللهِ ﷺ بَعْدَ مَا قَدِمَ الْمَدِينَةَ سِتَّةَ عَشَرَ شَهْرًا نَحْوَ بَيْتِ الْمَقْدِسِ ثُمَّ حُوِّلَ بَعْدَ ذَلِكَ قِبَلَ الْمَسْجِدِ الْحَرَامِ قَبْلَ بَدْرٍ بِشَهْرَيْنِ هَكَذَا  

رَوَاهُ الْعُطَارِدِيُّ عَنِ ابْنِ فُضَيْلٍ وَرَوَاهُ مَالِكٌ وَالثَّوْرِيُّ وَحَمَّادُ بْنُ زَيْدٍ عَنْ يَحْيَى بْنِ سَعِيدٍ عَنِ ابْنِ الْمُسَيِّبِ مُرْسَلًا دُونَ ذِكْرِ سَعْدٍ
suyuti:420-20b
Request/Fix translation

  

السيوطي:٤٢٠-٢٠b

"صَلَّى رَسُولُ الله ﷺ وَأَصْحَابُهُ إِلَى بَيْتِ الْمَقْدِسِ سِتَّة عَشَرَ شَهْرًا، ثُمَّ حُوِّلتْ الْقِبْلَةُ بَعْدُ".  

[ش] ابن أبى شيبة