Riyad Us-Saliheen (Gardens of the Righteous)
Chapter 208
Inducement to Perform Tahiyyat-ul-Masjid (Upon Entering the Mosque)
1144. Abu Qatadah (May Allah be pleased with him)reported: The Messenger of Allah (PBUH) said, "When anyone of you enters the mosque, he should perform two Rak`ah (of voluntary prayer) before sitting.''
[Al-Bukhari and Muslim].
1145. Jabir (May Allah be pleased with him) reported: I came to the Prophet (PBUH) when he was in the mosque, and he said to me, "Perform two Rak`ah prayer.''
[Al-Bukhari and Muslim].
Commentary: Both the foregoing Ahadith stress on performing two Rak`ah upon entering the mosque. According to Imam An-Nawawi's title of the chapter, everyone who comes to the mosque and performs Fard Salat or Sunnah Ratibah (compulsory), he will be exempted from performing two Rak`ah. Some `Ulama' are of the opinion that the order in this respect makes it compulsory, and for this reason they held Tahiyyat-ul-Masjid as Wajib (obligatory), while others think that it is a liked act (i.e., Mandub) and thus comes in the category of Mustahabb (desirable).