The Statement of Allah The fools (pagans, hypocrites and Jews) among the people will say, What has turned them (Muslims) from their Qiblah [Salat (prayer) direction (towards Jerusalem)]... (V.2:142)

Hadith Number 4486

setting

Narrated Al-Bara

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)