Hadithcore
Mishkat al-Masabih, 689, 690

Ibn ‘Abbas said that when the Prophet (ﷺ) entered the House (the Ka’ba) he made supplications in all sides of it, but did not perform <i>salat</i> till he had come out. When he came out he prayed two <i>rak'as</i> facing the Ka'ba and said, “This is the <i>qibla</i>.” Bukhari transmitted it and Muslim transmitted it from Ibn ‘Abbas from Usama b. Zaid.

عَنِ ابْنِ عَبَّاسٍ قَالَ: لَمَّا دَخَلَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ الْبَيْتَ دَعَا فِي نَوَاحِيهِ كُلِّهَا وَلَمْ يُصَلِّ حَتَّى خَرَجَ مِنْهُ فَلَمَّا خَرَجَ رَكَعَ رَكْعَتَيْنِ فِي قُبُلِ الْكَعْبَةِ وَقَالَ: «هَذِه الْقبْلَة» . رَوَاهُ البُخَارِيّ وَرَوَاهُ مُسْلِمٌ عَنْهُ عَنْ أُسَامَةَ بْنِ زَيْدٍ

References1 variant
In-Book Reference
Book 4, Hadith 121