All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
The majority of the jurists are of the view that the prayer of salutation to the Haraam mosque is to perform the Tawaaf (circumambulation around the Ka'bah) for a person who is entering Makkah, whether he is in a state of Ihraam, or for the purpose of trading, or else as 'Aa'ishah said: ''When the Prophet came to Makkah, he performed ablution and then performed the Tawaaf around the sacred House [Ka'bah].'' The two Rak'ahs that one performs after the Tawaaf are sufficient instead of the two Rak'ahs of salutation to the mosque.
However, if a person enters the mosque for other purposes than performing the Tawaaf, like for reciting the Quran, or seeking knowledge, or performing the obligatory prayer, then he should perform the two Rak'ahs of salutation to the mosque like any other mosque, for the general meaning of the saying of the Prophet said: “If one of you were to enter a mosque, he should not sit until he performs two Rak'ahs.”
However, we are not aware of any clear Prophetic narration which states that the salutation to the Haraam mosque is to perform the Tawaaf.