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.
bukhari:4486Abū Nuʿaym > Zuhayr > Abū Isḥāq > al-Barāʾ

The Prophet ﷺ prayed facing Bait-ulMaqdis (i.e. Jerusalem) for sixteen or seventeen months but he wished that his Qibla would be the Kaʿba (at Mecca). (So Allah Revealed (2.144) and he offered ʿAsr prayers(in his Mosque facing Kaʿba at Mecca) and some people prayed with him. A man from among those who had prayed with him, went out and passed by some people offering prayer in another mosque, and they were in the state of bowing. He said, "I, (swearing by Allah,) testify that I have prayed with the Prophet ﷺ facing Mecca." Hearing that, they turned their faces to the Kaʿba while they were still bowing. Some men had died before the Qibla was changed towards the Kaʿba. They had been killed and we did not know what to say about them (i.e. whether their prayers towards Jerusalem were accepted or not). So Allah revealed:-- "And Allah would never make your faith (i.e. prayer) to be lost (i.e. your prayers offered (towards Jerusalem). Truly Allah is Full of Pity, Most Merciful towards mankind." (2.143)  

البخاري:٤٤٨٦حَدَّثَنَا أَبُو نُعَيْمٍ سَمِعَ زُهَيْرًا عَنْ أَبِي إِسْحَاقَ عَنِ الْبَرَاءِ ؓ

أَنَّ رَسُولَ اللَّهِ ﷺ صَلَّى إِلَى بَيْتِ الْمَقْدِسِ سِتَّةَ عَشَرَ شَهْرًا أَوْ سَبْعَةَ عَشَرَ شَهْرًا وَكَانَ يُعْجِبُهُ أَنْ تَكُونَ قِبْلَتُهُ قِبَلَ الْبَيْتِ وَإِنَّهُ صَلَّى أَوْ صَلاَّهَا صَلاَةَ الْعَصْرِ وَصَلَّى مَعَهُ قَوْمٌ فَخَرَجَ رَجُلٌ مِمَّنْ كَانَ صَلَّى مَعَهُ فَمَرَّ عَلَى أَهْلِ الْمَسْجِدِ وَهُمْ رَاكِعُونَ قَالَ أَشْهَدُ بِاللَّهِ لَقَدْ صَلَّيْتُ مَعَ النَّبِيِّ ﷺ قِبَلَ مَكَّةَ فَدَارُوا كَمَا هُمْ قِبَلَ الْبَيْتِ وَكَانَ الَّذِي مَاتَ عَلَى الْقِبْلَةِ قَبْلَ أَنْ تُحَوَّلَ قِبَلَ الْبَيْتِ رِجَالٌ قُتِلُوا لَمْ نَدْرِ مَا نَقُولُ فِيهِمْ فَأَنْزَلَ اللَّهُ {وَمَا كَانَ اللَّهُ لِيُضِيعَ إِيمَانَكُمْ إِنَّ اللَّهَ بِالنَّاسِ لَرَءُوفٌ رَحِيمٌ }  


See similar narrations below:

Collected by Bukhārī, Aḥmad, Bayhaqī
bukhari:40ʿAmr b. Khālid > Zuhayr > Abū Isḥāq > al-Barāʾ

When the Prophet ﷺ came to Medina, he stayed first with his grandfathers or maternal uncles from Ansar. He offered his prayers facing Baitul-Maqdis (Jerusalem) for sixteen or seventeen months, but he wished that he could pray facing the Ka'ba (at Mecca). The first prayer which he offered facing the Ka'ba was the 'Asr prayer in the company of some people. Then one of those who had offered that prayer with him came out and passed by some people in a mosque who were bowing during their prayers (facing Jerusalem). He said addressing them, "By Allah, I testify that I have prayed with Messenger of Allah ﷺ facing Mecca (Ka'ba).' Hearing that, those people changed their direction towards the Ka'ba immediately. Jews and the people of the scriptures used to be pleased to see the Prophet ﷺ facing Jerusalem in prayers but when he changed his direction towards the Ka'ba, during the prayers, they disapproved of it. Al-Bara' added, "Before we changed our direction towards the Ka'ba (Mecca) in prayers, some Muslims had died or had been killed and we did not know what to say about them (regarding their prayers.) Allah then revealed: And Allah would never make your faith (prayers) to be lost (i.e. the prayers of those Muslims were valid).' " (2:143).  

البخاري:٤٠حَدَّثَنَا عَمْرُو بْنُ خَالِدٍ قَالَ حَدَّثَنَا زُهَيْرٌ قَالَ حَدَّثَنَا أَبُو إِسْحَاقَ عَنِ الْبَرَاءِ

أَنَّ النَّبِيَّ ﷺ كَانَ أَوَّلَ مَا قَدِمَ الْمَدِينَةَ نَزَلَ عَلَى أَجْدَادِهِ أَوْ قَالَ أَخْوَالِهِ مِنَ الأَنْصَارِ وَأَنَّهُ صَلَّى قِبَلَ بَيْتِ الْمَقْدِسِ سِتَّةَ عَشَرَ شَهْرًا أَوْ سَبْعَةَ عَشَرَ شَهْرًا وَكَانَ يُعْجِبُهُ أَنْ تَكُونَ قِبْلَتُهُ قِبَلَ الْبَيْتِ وَأَنَّهُ صَلَّى أَوَّلَ صَلاَةٍ صَلاَّهَا صَلاَةَ الْعَصْرِ وَصَلَّى مَعَهُ قَوْمٌ فَخَرَجَ رَجُلٌ مِمَّنْ صَلَّى مَعَهُ فَمَرَّ عَلَى أَهْلِ مَسْجِدٍ وَهُمْ رَاكِعُونَ فَقَالَ أَشْهَدُ بِاللَّهِ لَقَدْ صَلَّيْتُ مَعَ رَسُولِ اللَّهِ ﷺ قِبَلَ مَكَّةَ فَدَارُوا كَمَا هُمْ قِبَلَ الْبَيْتِ وَكَانَتِ الْيَهُودُ قَدْ أَعْجَبَهُمْ إِذْ كَانَ يُصَلِّي قِبَلَ بَيْتِ الْمَقْدِسِ وَأَهْلُ الْكِتَابِ فَلَمَّا وَلَّى وَجْهَهُ قِبَلَ الْبَيْتِ أَنْكَرُوا ذَلِكَ قَالَ زُهَيْرٌ حَدَّثَنَا أَبُو إِسْحَاقَ عَنِ الْبَرَاءِ فِي حَدِيثِهِ هَذَا أَنَّهُ مَاتَ عَلَى الْقِبْلَةِ قَبْلَ أَنْ تُحَوَّلَ رِجَالٌ وَقُتِلُوا فَلَمْ نَدْرِ مَا نَقُولُ فِيهِمْ فَأَنْزَلَ اللَّهُ تَعَالَى {وَمَا كَانَ اللَّهُ لِيُضِيعَ إِيمَانَكُمْ}  

ahmad:18496Ḥasan b. Mūsá > Zuhayr > Abū Isḥāq > al-Barāʾ b. ʿĀzib

[Machine] The Prophet ﷺ was the first to arrive in Medina and stayed with his ancestors and extended family from the Ansar. He prayed facing the direction of Bait al-Maqdis (Jerusalem) for sixteen or seventeen months, and he preferred for his qibla (direction of prayer) to be towards the Kaaba. He also prayed the Asr prayer as the first prayer he offered in Medina, and some people prayed with him. A man who had prayed with him later passed by a group of people who were in the state of rukoo' (bowing) in prayer and said, "I bear witness by Allah that I have prayed with the Messenger of Allah ﷺ facing towards Makkah." They turned and faced the Kaaba in prayer. It pleased the Prophet ﷺ to have the qibla changed, and the Jews were amazed when he used to pray facing Bait al-Maqdis, just as the people of the Book were. However, when he turned his face towards the Kaaba they disapproved of it.  

أحمد:١٨٤٩٦حَدَّثَنَا حَسَنُ بْنُ مُوسَى حَدَّثَنَا زُهَيْرٌ حَدَّثَنَا أَبُو إِسْحَاقَ عَنِ الْبَرَاءِ بْنِ عَازِبٍ

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

bayhaqi:2191Abū ʿAbdullāh al-Ḥāfiẓ > Abū Bakr Aḥmad b. Salmān b. al-Ḥasan al-Faqīh > Aḥmad b. Muḥammad b. ʿĪsá > Abū Nuʿaym > Zuhayr > Abū Isḥāq > al-Barāʾ b. ʿĀzib

The Prophet ﷺ prayed facing Bait-ulMaqdis (i.e. Jerusalem) for sixteen or seventeen months but he wished that his Qibla would be the Kaʿba (at Mecca). (So Allah Revealed (2.144) and he offered ʿAsr prayers(in his Mosque facing Kaʿba at Mecca) and some people prayed with him. A man from among those who had prayed with him, went out and passed by some people offering prayer in another mosque, and they were in the state of bowing. He said, "I, (swearing by Allah,) testify that I have prayed with the Prophet ﷺ facing Mecca." Hearing that, they turned their faces to the Kaʿba while they were still bowing. Some men had died before the Qibla was changed towards the Kaʿba. They had been killed and we did not know what to say about them (i.e. whether their prayers towards Jerusalem were accepted or not). So Allah revealed:-- "And Allah would never make your faith (i.e. prayer) to be lost (i.e. your prayers offered (towards Jerusalem). Truly Allah is Full of Pity, Most Merciful towards mankind." (2.143) (Using translation from Bukhārī 4486)   

البيهقي:٢١٩١أَخْبَرَنَا أَبُو عَبْدِ اللهِ الْحَافِظُ أنبأ أَبُو بَكْرٍ أَحْمَدُ بْنُ سَلْمَانَ بْنِ الْحَسَنِ الْفَقِيهُ ثنا أَحْمَدُ بْنُ مُحَمَّدِ بْنِ عِيسَى ثنا أَبُو نُعَيْمٍ ثنا زُهَيْرٌ عَنْ أَبِي إِسْحَاقَ عَنِ الْبَرَاءِ بْنِ عَازِبٍ

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