As for the first of the two reports: the Prophet ﷺ endorsed ʿĀʾishah’s wish to pray inside the Kaʿbah, yet he instructed her to pray in the ḥijr—the semicircular annex—explaining that it, too, belongs to the House. This shows that prayer is lawful anywhere within the Kaʿbah, the ḥijr included. He probably directed her to the ḥijr rather than the inner chamber on that occasion because it was easier for her to reach and kept her farther from mixing with men.
Regarding the second report, the Prophet ﷺ implicitly permitted prayer inside the Kaʿbah when he ordered the removal of anything that might distract a worshipper from humility there.
Al-Ṭaḥāwī—may Allah have mercy on him—cited both ḥadiths as proof of this permissibility, and he related the view from Abū Ḥanīfah and his two companions. As noted earlier, it is also the position of the majority. The Shāfiʿīs went further, holding that voluntary prayer inside the Kaʿbah is superior to praying outside it, and the same applies to an obligatory prayer provided no larger congregation is expected elsewhere and those present can perform the prayer inside. If that is not feasible, then praying outside is better. Al-Shāfiʿī said, “There is no place better or purer for prayer than the Kaʿbah.”
Al-Nawawī records this statement in al-Majmūʿ and then comments: “If it be asked: How can you state categorically that praying inside the Kaʿbah is better than outside it when scholars disagree about its validity and it is recommended to avoid points of disagreement? The answer is that we recommend avoiding only a disagreement that is worthy of consideration—that is, a disagreement arising from legitimate ijtihād. When an opposing view conflicts with an authentic sunnah, as it does in this case, it carries no weight and no…"