"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."
لَمَّا قَدِمَ رَسُولُ اللَّهِ ﷺ الْمَدِينَةَ صَلَّى نَحْوَ بَيْتِ الْمَقْدِسِ سِتَّةَ أَوْ سَبْعَةَ عَشَرَ شَهْرًا وَكَانَ رَسُولُ اللَّهِ ﷺ يُحِبُّ أَنْ يُوَجَّهَ إِلَى الْكَعْبَةِ فَأَنْزَلَ اللَّهُ ( قَدْ نَرَى تَقَلُّبَ وَجْهِكَ فِي السَّمَاءِ فَلَنُوَلِّيَنَّكَ قِبْلَةً تَرْضَاهَا فَوَلِّ وَجْهَكَ شَطْرَ الْمَسْجِدِ الْحَرَامِ ) فَوَجَّهَ نَحْوَ الْكَعْبَةِ وَكَانَ يُحِبُّ ذَلِكَ فَصَلَّى رَجُلٌ مَعَهُ الْعَصْرَ قَالَ ثُمَّ مَرَّ عَلَى قَوْمٍ مِنَ الأَنْصَارِ وَهُمْ رُكُوعٌ فِي صَلاَةِ الْعَصْرِ نَحْوَ بَيْتِ الْمَقْدِسِ فَقَالَ هُوَ يَشْهَدُ أَنَّهُ صَلَّى مَعَ رَسُولِ اللَّهِ ﷺ وَأَنَّهُ قَدْ وُجِّهَ إِلَى الْكَعْبَةِ قَالَ فَانْحَرَفُوا وَهُمْ رُكُوعٌ