It is narrated from Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) that when the Prophet (peace and blessings be upon him) was turned towards the Ka'bah, the people said: "O Messenger of Allah, what will become of our brothers who died before this, who died while they were praying towards Bayt al-Maqdis?" So Allah, the Mighty and Majestic, revealed this verse: "And Allah would never let your faith go to waste."
Imam Ahmad (may Allah have mercy on him) also narrated this hadith through Yahya bin Adam, Khalaf bin al-Walid and Shadhan from Isra'il.
And Imam Abu Dawud (may Allah have mercy on him) narrated it from Muhammad bin Sulayman al-Anbari and Uthman, from Waki', from Sufyan, from Simak.
And Imam al-Tirmidhi (may Allah have mercy on him) narrated it from Hannad and Abu Ammar, from Waki', from Isra'il, and said: "This hadith is hasan sahih."
And Abu Hatim al-Busti (Ibn Hibban) (may Allah have mercy on him) narrated it from Abu Ya'la al-Mawsili (may Allah have mercy on him).