Is praying tahiyyatul masjid an obligation?

In the name of Allah, the Gracious, the Merciful

Scholars disagree whether praying two bowings of prayer (raka’at) when entering the mosque is an obligation (wajib) or a recommendation (mustahab). The primary evidence under discussion is the following narration:

Abu Qatadah reported: The Messenger of Allah, peace and blessings be upon him, said:

إِذَا دَخَلَ أَحَدُكُمْ الْمَسْجِدَ فَلْيَرْكَعْ رَكْعَتَيْنِ قَبْلَ أَنْ يَجْلِسَ

When one of you enters the mosque, then let him pray two bowings before he sits down.

Source: Sahih Bukhari 433, Grade: Muttafaqun Alayhi

In another narration, the Prophet said:

فَلَا يَجْلِسْ حَتَّى يَرْكَعَ رَكْعَتَيْنِ

Let him not sit down until he prays two bowings.

Source: Sahih Muslim 714, Grade: Sahih

An-Nawawi comments on these traditions, saying:

فِيهِ اسْتِحْبَابُ تَحِيَّةِ الْمَسْجِدِ بِرَكْعَتَيْنِ وَهِيَ سُنَّةٌ بِإِجْمَاعِ الْمُسْلِمِينَ وَحَكَى الْقَاضِي عِيَاضٌ عَنْ دَاوُدَ وَأَصْحَابِهِ وُجُوبَهُمَا وَفِيهِ التَّصْرِيحُ بِكَرَاهَةِ الْجُلُوسِ بِلَا صَلَاةٍ وَهِيَ كَرَاهَةُ تَنْزِيهٍ

In this tradition is the recommendation to greet the mosque with two bowings of prayer and it is the prophetic tradition (sunnah) according to the consensus of the Muslims. It was narrated by Al-Qadi Iyad from Dawud and his companions that it is an obligation. In this is an indication that it is disapproved to sit without performing prayer and its disapproval is of a suggestive nature.

Source: Sharh Sahih Muslim

Scholars such as Al-Qadi Iyad and others who maintain that two bowings are an obligation take the order of the Prophet as a general command. Other scholars such as Imam Muslim and An-Nawawi maintain that two bowings are a recommendation and not an obligation.

There is some evidence to indicate that the two bowings are recommended and not obligatory.

Abdullah ibn Busr reported: A man came to the Friday prayer stepping over the necks of people while the Prophet, peace and blessings be upon him, was delivering a sermon. The Prophet said:

اجْلِسْ فَقَدْ آذَيْتَ

Sit down, for you have caused a disturbance.

Source: Sunan Abu Dawud 1118, Grade: Sahih

In this tradition, the Prophet told the man to sit down without ordering him to perform two bowings of prayer. If the two bowings had been a firm obligation, the Prophet would have ordered him to do so.

Nevertheless, it is disapproved (makruh) to enter the mosque and not perform the greeting prayer. We should practice this prophetic tradition in general and it may become sinful if we habitually leave it for no good reason.

Success comes from Allah, and Allah knows best.