Is the voluntary prayer (Nafl) valid inside the Kaaba or on its roof?
Chapter on Praying with Impurity and Other Matters
Al-Mughni
Book of Prayer
Primary text
The voluntary prayer is valid inside the Kaaba and on its roof. There is no known disagreement on this matter. The evidence is that the Prophet, peace and blessings be upon him, prayed two rak'ahs inside the House (the Kaaba).
Supporting text
If the one praying faces the door or is on the roof, and there is something connected to the Kaaba structure in front of him, his prayer is valid. If there is nothing prominent in front of him, or if there is stacked brick (ajur mu'abba) that is not built, or wood not nailed into it, the prayer is invalid because he is not facing any part of it. However, if the wood is nailed or the brick is built, the prayer is valid as that structure is considered subsidiary to it.