Sunan Ibn Majah – Hadith No : 1063

It wasnarrated that Bara’ said: “We prayed with the Messenger ofAllah(ﷺ) facing towards Baitul-Maqdis (Jerusalem) for eighteenmonths,then the Qiblah was changed to the Ka’bah two months after theProphet (ﷺ) entered Al-Madinah. When the Messenger of Allah (ﷺ)prayed towards Baitul-Maqdis, he would often lift his face towardstheheavens, and Allah knew what was in the heart of His Prophet andhowhe longed to face the Ka’bah (during prayer). Jibril appeared(in thesky), and the Messenger of Allah (ﷺ) started watching himas he wasdescending between the heavens and the earth, waiting tosee what hewould bring. Then Allah revealed the words: ‘Verily, Wehave seen theturning of your face towards the heaven. Surely, Weshall turn you toa Qiblah that shall please you, so turn your facein the direction ofAl-Masjid Al-Haram (at Makkah). And wherever youpeople are, turn yourfaces (during prayer) in that direction.’[2:144] Then someone came tous and said: ‘The Qiblah has beenchanged to the Ka’bah.’ We hadperformed two Rak’ah facingtowards Jerusalem. And we were bowing. Sowe turned around, and wecontinued our prayer. The Messenger of Allah(ﷺ) said: ‘O Jibril!What about our prayer facing towards Baitul-Maqdis?’ Then Allahrevealed the words: “And Allah would never makeyour faith to belost.” [2:143]

Hadith In Arabic Text :

حدثنا علقمة بن عمرو الدارمي، حدثنا أبو بكر بن عياش، عن أبي إسحاق، عن البراء، قال صلينا مع رسول الله صلى الله عليه وسلم نحو بيت المقدس ثمانية عشر شهرا وصرفت القبلة إلى الكعبة بعد دخوله إلى المدينة بشهرين وكان رسول الله صلى الله عليه وسلم إذا صلى إلى بيت المقدس أكثر تقلب وجهه في السماء وعلم الله من قلب نبيه صلى الله عليه وسلم أنه يهوى الكعبة فصعد جبريل فجعل رسول الله صلى الله عليه وسلم يتبعه بصره وهو يصعد بين السماء والأرض ينظر ما يأتيه به فأنزل الله ‏{قد نرى تقلب وجهك في السماء}‏ الآية فأتانا آت فقال إن القبلة قد صرفت إلى الكعبة وقد صلينا ركعتين إلى بيت المقدس ونحن ركوع فتحولنا فبنينا على ما مضى من صلاتنا فقال رسول الله صلى الله عليه وسلم ‏”‏ يا جبريل كيف حالنا في صلاتنا إلى بيت المقدس ‏”‏ ‏.‏ فأنزل الله عز وجل ‏{وما كان الله ليضيع إيمانكم}‏ ‏.‏

Chapter : Establishing the Prayer and the Sunnah Regarding Them – كتاب إقامة الصلاة والسنة فيها