What is greeting the mosque? How to perform of tahiyyat al masjid?
Abu Qatada, a Companion of the Messenger of Allah (pbuh), said: I entered the mosque, when the Messenger of Allah (pbuh) had been sitting among people, and I also sat down among them. Upon this the Messenger of Allah (pbuh) said:
“What prevented you from offering two rak’ahs (of Nafl prayer) before sitting down?”
I said: Messenger of Allah, I saw you sitting and people sitting (around you and I, therefore, sat in your company). He (the Holy Prophet) then said:
“When anyone among you enters the mosque, he should not sit till he has observed two rak’ahs.” (Muslim, Musafirun, 70)
There are other prophetic sayings which advise to offer tahiyyat al-masjid prayer when visiting a mosque. The term tahiyyat al-masjid means to salute the mosque. Mosques are the houses of Allah. There is nothing more natural than saluting the owner of the house when entering it. In a way by performing tahiyyat al-masjid prayer, believers salute Allah the Almighty, offer Him his submission, respect, and servitude. However, this prayer should not be performed during prohibited times of the day.
Source: An Excellent Exemplar, Osman Nuri Topbaş, Erkam Publications