Sunan an-Nasa'i, Hadith 742 ⓘ
Narrated Al Bara bin Azib: Al Bara bin Azib said: The messenger of Allah (peace be upon him) came to Al-Madinah and prayed toward Bait-al-Maqdis for sixteen months, then he was commanded to pray toward the Ka'bah. A man who had prayed with the prophet (peace be upon him)passed by some of the Ansar and said: "I bear witness that the messenger of Allah (peace be upon him) has been commanded to face toward the Ka'bah. So they turned to face the Ka'bah".
أَخْبَرَنَا مُحَمَّدُ بْنُ إِسْمَاعِيلَ بْنِ إِبْرَاهِيمَ، قَالَ حَدَّثَنَا إِسْحَاقُ بْنُ يُوسُفَ الأَزْرَقُ، عَنْ زَكَرِيَّا بْنِ أَبِي زَائِدَةَ، عَنْ أَبِي إِسْحَاقَ، عَنِ الْبَرَاءِ بْنِ عَازِبٍ، قَالَ قَدِمَ رَسُولُ اللَّهِ صلى الله عليه وسلم الْمَدِينَةَ فَصَلَّى نَحْوَ بَيْتِ الْمَقْدِسِ سِتَّةَ عَشَرَ شَهْرًا ثُمَّ وُجِّهَ إِلَى الْكَعْبَةِ فَمَرَّ رَجُلٌ قَدْ كَانَ صَلَّى مَعَ النَّبِيِّ صلى الله عليه وسلم عَلَى قَوْمٍ مِنَ الأَنْصَارِ فَقَالَ أَشْهَدُ أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَدْ وُجِّهَ إِلَى الْكَعْبَةِ . فَانْحَرَفُوا إِلَى الْكَعْبَةِ .
also referenced under: Book 9, Hadith 1 (In-Book) & Volume 1, Book 9, Hadith 743 (DarusSalam)