Imam Bukhari narrates: Abdullah bin Raja narrated to us, he said: Israil narrated to us, from Abu Ishaq from Hazrat Al-Bara bin Azib, Allah be pleased with him, he narrates that
the Messenger of Allah ﷺ prayed facing towards Bait al-Maqdis for sixteen or seventeen months, and the Messenger of Allah ﷺ liked that he be turned towards the Ka'bah, then Allah, Mighty and Majestic, revealed this verse: We see the turning of your face again and again towards the sky. (Al-Baqarah: ) Then he was turned towards the Ka'bah, and among the people, the ignorant ones said, and they were the Jews: What has turned them away from their qiblah, upon which they were before? Say: The East and the West belong to Allah alone. He guides whom He wills towards the straight path. (Al-Baqarah: ) Then a person prayed along with the Prophet ﷺ, he came out after praying and passed by the people of the Ansar who were praying the Asr prayer facing towards Bait al-Maqdis, so he said: He bears witness that he has (just now) prayed along with the Messenger of Allah ﷺ and he was facing towards the Ka'bah, then those people turned and they faced towards the Ka'bah.
Reference: Sahih Al Bukhari 399