Sahih al-Bukhari, Book 8, Hadith 50 (In-Book) ⓘ
Narrated Bara' bin `Azib: Allah's Messenger prayed facing Baitul-Maqdis for sixteen or seventeen months but he loved to face the Ka`ba (at Mecca) so Allah revealed: "Verily, We have seen the turning of your face to the heaven!" (2:144) So the Prophet faced the Ka`ba and the fools amongst the people namely "the Jews" said, "What has turned them from their Qibla (Baitul-Maqdis) which they formerly observed"" (Allah revealed): "Say: 'To Allah belongs the East and the West. He guides whom he will to a straight path'." (2:142) A man prayed with the Prophet (facing the Ka`ba) and went out. He saw some of the Ansar praying the `Asr prayer with their faces towards Baitul-Maqdis, he said, "I bear witness that I prayed with Allah's Messenger facing the Ka`ba." So all the people turned their faces towards the Ka`ba.
حَدَّثَنَا عَبْدُ اللَّهِ بْنُ رَجَاءٍ، قَالَ حَدَّثَنَا إِسْرَائِيلُ، عَنْ أَبِي إِسْحَاقَ، عَنِ الْبَرَاءِ بْنِ عَازِبٍ ـ رضى الله عنهما ـ قَالَ كَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم صَلَّى نَحْوَ بَيْتِ الْمَقْدِسِ سِتَّةَ عَشَرَ أَوْ سَبْعَةَ عَشَرَ شَهْرًا، وَكَانَ رَسُولُ اللَّهِ صلى الله عليه وسلم يُحِبُّ أَنْ يُوَجَّهَ إِلَى الْكَعْبَةِ، فَأَنْزَلَ اللَّهُ {قَدْ نَرَى تَقَلُّبَ وَجْهِكَ فِي السَّمَاءِ} فَتَوَجَّهَ نَحْوَ الْكَعْبَةِ، وَقَالَ السُّفَهَاءُ مِنَ النَّاسِ ـ وَهُمُ الْيَهُودُ ـ مَا وَلاَّهُمْ عَنْ قِبْلَتِهِمُ الَّتِي كَانُوا عَلَيْهَا {قُلْ لِلَّهِ الْمَشْرِقُ وَالْمَغْرِبُ يَهْدِي مَنْ يَشَاءُ إِلَى صِرَاطٍ مُسْتَقِيمٍ} فَصَلَّى مَعَ النَّبِيِّ صلى الله عليه وسلم رَجُلٌ ثُمَّ خَرَجَ بَعْدَ مَا صَلَّى، فَمَرَّ عَلَى قَوْمٍ مِنَ الأَنْصَارِ فِي صَلاَةِ الْعَصْرِ نَحْوَ بَيْتِ الْمَقْدِسِ فَقَالَ هُوَ يَشْهَدُ أَنَّهُ صَلَّى مَعَ رَسُولِ اللَّهِ صلى الله عليه وسلم، وَأَنَّهُ تَوَجَّهَ نَحْوَ الْكَعْبَةِ. فَتَحَرَّفَ الْقَوْمُ حَتَّى تَوَجَّهُوا نَحْوَ الْكَعْبَةِ.
also referenced under: Hadith 399 (DarusSalam) & Volume 1, Book 8, Hadith 392 (USC-MSA)