The Messenger of Allah ﷺ prayed facing Bayt al-Maqdis for sixteen or seventeen months, but he wished that his prayer direction would be toward the Kaaba. He prayed, or led, the afternoon prayer, and a group of people prayed with him. One of those who had prayed with him went out and passed by some people in a mosque while they were bowing in prayer. He said, "I bear witness by Allah that I have just prayed with the Prophet ﷺ facing Mecca." So they turned, just as they were, to face the Kaaba.Some men who had died while still praying toward the original direction, before it was changed to the Kaaba, had been killed, and we did not know what to say about them. Then Allah revealed, "And Allah would never let your faith go to waste. Indeed, Allah is Most Kind and Merciful to people" [Baqarah 2:143].
حدثنا أبو نعيم سمع زهيرا عن أبي إسحاق
أن رسول الله ﷺ صلى إلى بيت المقدس ستة عشر شهرا أو سبعة عشر شهرا وكان يعجبه أن تكون قبلته قبل البيت وأنه صلى أو صلاها صلاة العصر وصلى معه قوم فخرج رجل ممن كان صلى معه فمر على أهل المسجد وهم راكعون قال أشهد بالله لقد صليت مع النبي ﷺ قبل مكة فداروا كما هم قبل البيت وكان الذي مات على القبلة قبل أن تحول قبل البيت رجال قتلوا لم ندر ما نقول فيهم فأنزل الله {وما كان الله ليضيع إيمانكم إن الله بالناس لرءوف رحيم}