Praise be to Allah.
We have previously explained that it is a mistake to call al-Hijr “Hijr Ismaa‘eel”, because this Hijr only became a Hijr a long time after the time of Ismaa‘eel (peace be upon him). The correct form is to call it al-Hijr only, without attributing it to anyone.
See question number 22004.
The Hijr is part of the Ka‘bah, so whoever prays in it has prayed in the Ka‘bah, and praying in the Ka‘bah is permissible with regard to naafil prayers only, as the Prophet (blessings and peace of Allah be upon him) did. Al-Bukhaari (505) and Muslim (1329) narrated from ‘Abd-Allah ibn ‘Umar that the Messenger of Allaah (blessings and peace of Allah be upon him) entered the Ka’bah, accompanied by Usaamah, Bilaal and ‘Uthmaan ibn Talhah al-Hajabi. He closed the door and remained inside. Ibn ‘Umar said: I asked Bilaal when he came out: What did the Messenger of Allaah (blessings and peace of Allah be upon him) do? He said: He put two pillars on his left, one pillar on his right, and three pillars behind him – and at that time the House was built on six pillars – then he prayed.
Abu Dawood (2028), al-Tirmidhi (876) and al-Nasaa’i (2912) narrated from ‘Aa’ishah that she said: I wanted to enter the House (the Ka‘bah) and pray inside it, but the Messenger of Allah (blessings and peace of Allah be upon him) took me by the hand and led me into al-Hijr and said: “Pray in al-Hijr if you want to enter the House, for it is a part of the House, but your people ran out of funds when they (re)built the Ka‘bah, so they left it outside the House.”
Ibn Qudaamah (may Allah have mercy on him) said: Obligatory (fard) prayers are not valid inside the Ka‘bah or on its roof, but they were regarded as permissible by al-Shaafa‘i and Abu Haneefah, because it is a mosque and because it is a place for naafil praying, so it should be a place for obligatory prayers too, just like the area outside it. But Allah says (interpretation of the meaning): “And from wheresoever you start forth (for prayers), turn your face in the direction of Al-Masjid Al-Haraam (at Makkah)” [al-Baqarah 2:149]. The worshipper who is inside it or on its roof is not facing towards it. But the basic principle with regard to naafil prayers is that the rulings on them are less stringent, based on the fact that they may be prayed whilst seated, facing a direction other than the qiblah, and, when travelling, on one’s mount.
Then he said: Naafil prayers are valid if offered inside the Ka‘bah or on its roof, and we do not know of any difference of opinion concerning that, because the Prophet (blessings and peace of Allah be upon him) prayed two rak‘ahs inside the Ka‘bah.
End quote from al-Mughni, 1/406
Shaykh Ibn Baaz (may Allah have mercy on him) was asked about praying inside it, and whether there is any advantage in doing so.
He replied: Praying inside Hijr Ismaa‘eel is mustahabb, because it is part of the Ka‘bah, and it is narrated in a saheeh report from the Prophet (blessings and peace of Allah be upon him) that he entered the Ka‘bah during the year of the conquest (of Makkah) and prayed two rak‘ahs inside it. The soundness of this hadith is agreed upon; the hadeeth was narrated from Ibn ‘Umar and Bilaal (may Allah be pleased with them).
It is proven that the Prophet (blessings and peace of Allah be upon him) said to ‘Aa’ishah when she wanted to enter the Ka‘bah: “Pray in al-Hijr,” because it is part of the House (the Ka‘bah).
With regard to obligatory prayers, it is better not to offer them inside the Ka‘bah or in Hijr Ismaa‘eel, because the Prophet (blessings and peace of Allah be upon him) did not do that, and because some of the scholars said that it (obligatory prayer) is not valid inside the Ka‘bah or in al-Hijr, because al-Hijr is part of the Ka‘bah.
Thus it is known that what is prescribed is to offer obligatory prayers outside the Ka‘bah and outside al-Hijr, following the example of the Prophet (blessings and peace of Allah be upon him), and so as to avoid differing from those scholars who say that obligatory prayer offered inside the Ka‘bah or in al-Hijr is not valid.
And Allah is the source of strength.
End quote from Fataawa al-Shaykh Ibn Baaz (11/389)
To sum up: prayer inside al-Hijr is mustahabb, but it should be limited to naafil prayers.
And Allah knows best.