Short answer
Tahiyyat al-masjid (greeting the mosque) is two rakats prayed on entering a masjid before you sit down. It is sunnah, not obligatory. Any prayer you pray on entering, such as a sunnah or the fard, also counts for it. In the Hanafi school it is not prayed in the disliked times, such as after the Asr fard, or during the khutbah.
Two rakats on entering the masjid are mustahabb for anyone who enters at a time when prayer is allowed. Any fard or sunnah prayed on entering covers them. They are not prayed in the forbidden and disliked times or once the imam has come out for the khutbah, and sitting down first does not make them lapse.
Other madhhabs
- Shafi'i
- They are prayed even in the disliked times and during the Friday khutbah, because they have a specific cause.
- Hanbali
- They are prayed lightly during the Friday khutbah.
Explanation
The Prophet ﷺ said that when one of you enters the masjid, he should pray two rakats before he sits. These two rakats are called tahiyyat al-masjid, the greeting of the masjid. They are a sunnah of respect for the house of Allah, not an obligation.
- Any prayer counts: if you go straight into the sunnah of Dhuhr, or join the congregation, that covers it. Intending both is good.
- Sat down first? In the Hanafi school you can still stand and pray them.
- Entering many times a day: praying them once that day is enough.
- Disliked times: after the Fajr fard, after the Asr fard, and the three forbidden times, do not pray them. Some Hanafi scholars recommend saying "Subhanallah, walhamdulillah, wa la ilaha illallah, wallahu akbar" instead.
- During the khutbah: sit and listen; see talking or praying during the khutbah.
A prayer room at work, university or an airport is often not a masjid in the legal sense, so these two rakats are not specifically prescribed there, though nafl is always welcome outside the disliked times. At Masjid al-Haram in Makkah, tawaf takes the place of this prayer for someone who intends to do tawaf.
Say the du'a for entering the masjid as you go in. For the times to avoid, see the forbidden times for prayer.
The evidence
Sahih al-Bukhari 444
Sahih... إذا دخل أحدكم المسجد فليركع ركعتين قبل أن يجلس ...
"When one of you enters the masjid, let him pray two rakats before he sits."
The basis of tahiyyat al-masjid.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Kitab al-Salah, chapter on witr and nawafil. Two rakats on entering the masjid are recommended, are covered by any prayer, and are not prayed in disliked times.
- Nur al-Idah with Maraqi al-Falah, Chapter on nawafil. Lists tahiyyat al-masjid among the recommended prayers.
- al-Majmu' (Nawawi), Chapter on the times in which prayer is forbidden. The Shafi'i view that prayers with a cause, such as tahiyyat al-masjid, are allowed in disliked times.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.