Bara bin Azib reported,

The Messenger of Allah ﷺ prayed toward Bayt al-Maqdis for sixteen or seventeen months, though he wished his prayer direction would be toward the Kabah. He prayed the afternoon prayer, and a group of people prayed with him.One of those who had prayed with him went out and passed by the people of 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, toward the Kabah.Among those who had died facing the former prayer direction, before it was changed to the Kabah, were some men who had been killed, and we did not know what to say about them. Then Allah revealed, "And never would Allah have caused your faith to be lost. Indeed Allah is, to the people, Kind and Merciful" [Baqarah 2:143].

Azami 11925

Sahih

عن البراء

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

الأعظمي 11925صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Tafsir of the great Quran
Chapter
Virtues of Surah Baqarah
Section
His saying, "The foolish among the people will say, 'What has turned them away from their qibla which they used to face?' Say, 'To Allah belongs the east and the Maghrib. He guides whom He wills to a straight path.' And thus We have made you a moderate nation that you will be witnesses over the people and the Messenger will be a witness over you. And We did not make the qibla which you used to face except that We might make evident who would follow the Messenger from who would turn back on his heels. And indeed, it was difficult except for those whom Allah has guided. And never would Allah cause your faith to be lost."
Numbering
Jami al-Kamil 11925 (2nd edition)
Azami 11925