The Prophet ﷺ, when he entered the House, made supplication in all of its corners and did not pray inside it until he came out. Once he came out, he prayed two rakahs facing the House and said, "This is the qiblah."
أن النبي ﷺ الا لما دخل البيت دعا في نواحيه كلها، ولم يصل فيه حتى خرج. فلما خرج ركع في قبل البيت ركعتين، وقال: هذه القبلة.
Muslim narrated it in the Hajj chapter (1330) via Muhammad bin Bakr, from Ibn Jurayj, who said, I said to Ataa, "Did you hear Ibn Abbas say, 'You have only been commanded to perform tawaf, and you have not been commanded to enter it'?" He said, "He did not forbid entering it, but I heard him say, 'Usama bin Zayd told me,'" and then he related the hadith.But Bukhari narrated it in the Prayer chapter (398) via Abdul-Razzaq, who said, Ibn Jurayj told us, from Ataa, who said, I heard Ibn Abbas say, "When the Prophet ﷺ entered the House, he supplicated in all its corners and did not pray until he came out of it. When he came out, he prayed two rakahs facing the Kaaba and said, 'This is the qibla.'" So he made the hadith part of the narration of Ibn Abbas.Ibn Hajar judged it more likely to belong to the narration of Usama. This negation does not contradict what Bilal narrated about the Messenger of Allah ﷺ praying inside the Kaaba, and the reconciliation between the two will come in the book of Hajj, Allah willing.