Narrated Al-Bara bin 'Azib:
"When the Messenger of Allah (ﷺ) arrived in Al-Madinah, he performed Salat facing the direction of Bait Al-Maqdis (Jerusalem) for sixteen or seventeen months. The Messenger of Allah (ﷺ) longed to face toward the Ka'bah, so Allah, Might and Sublime is He revealed: Verily, WE have seen the turning of your face towards the heave. Surely, We Shall turn your face in the direction of Al-Masjid Al-Haram (2:144). So he faced the direction of the Ka'bah and he longed for that. (One day) a man performed Salat Al-'Asr along with him." He said: "Then he passed by some people of the Ansar performing Salat Al-'Asr, while they were bowing toward Bait Al-Maqdis. He told them that he testifies that he performed Salat with the Messenger of Allah (ﷺ), and he had faced the direction of the Ka'bah." He said: "So they turned while they were bowing."
English reference: Vol. 5, Book 44, Hadith 2962
Arabic reference: Book 47, Hadith 3225