There has been a post on this topic before, but this will be more detailed and insightful inshaAllah.
Volume 2, Book 13, Number 750:
Narrated Jabir bin ‘Abdullah:
A person entered the mosque while the Prophet was delivering the Khutba on a Friday. The Prophet said to him, “Have you prayed?” The man replied in the negative. The Prophet said, “Get up and pray two Rakat.”
Volume 2, Book 13, Number 751:
A man entered the Mosque while the Prophet was delivering the Khutba. The Prophet said to him, “Have you prayed?” The man replied in the negative. The Prophet said, “Pray two Rakat.”
One of the etiquettes of visiting the Masjid, is the offering of two rak`aat glorifying Allaah upon arrival. These two rak`aat show honor and respect for the places of worship. These two rak`aat are known as “Tahiyyaht-ul-Masjid”, and display salutation for the masjid. The person entering the masjid performs them greeting the masjid; similar to the way a person greets somebody.
There is proof found in the hadeeth of Abu Qaatadah that this prayer is legislated. The Prophet (peace and blessings be upon him) said,
إِذَا دَخَلَ أَحَدُكُمُ الْمَسْجِدَ فَلاَ يَجْلِسْ حَتَّى يُصَلِّىَ رَكْعَتَيْنِ
“Whenever one of you enter the masjid he MUST not sit down until he prays two Rak’ah.” (Bukhari 433)
فَلْيَرْكَعْ رَكْعَتَيْنِ قَبْلَ أَنْ يَجْلِسَ
“Then he MUST pray two Rak’ah before he sits down”(Muslim 714)
In the Ahadith mentioned above (top), an instance is mentioned where Prophet (SAW) interrupts his khutba to ask a man if he had prayed tahiyyat-ul-masjid upon entering the masjid. And then he ordered him to get up and pray the two rak`aat. This is where the confusion starts. Is the Jumu`ah khutba more important or the tahiyyat-ul-masjid? Well, read point 4 here.
Is it mandatory, recommended, or just a voluntary deed? Does a person HAVE to perform these two rak`aat upon entering a masjid, or does he/she have an option? Well, there’s difference of opinion among scholars. Go through this link for details. In short, it is recommended and a “stressed Sunnah”.
So if it’s a stressed Sunnah, can we perform the two rak`aat even in the times when prayer is forbidden (example: after Fajr, after Asr)? Get your answer here.
Happy knowing + amal-ing. :D
Narrated Imran bin Husain:
I offered the prayer with ‘Ali in Basra and he made us remember the prayer which we used to pray with Allah’s Apostle. ‘Ali said Takbir on each rising and bowing.
Narrated Abu Salama:
When Abu Huraira led us in prayer he used to say Takbir on each bowing and rising. On the completion of the prayer he used to say, “My prayer is more similar to the prayer of Allah’s Apostle than that of anyone of you.”
Narrated Mutarrif bin ‘Abdullah:
‘Imran bin Husain and I offered the prayer behind Ali bin Abi Talib. When ‘Ali prostrated, he said the Takbir, when he raised his head, he said the Takbir and when he got up for the third Rak’a he said the Takbir. On completion of the prayer Imran took my hand and said, “This (i.e. ‘Ali) made me remember the prayer of Muhammad” Or he said, “He led us in a prayer like that of Muhammad.”
I saw a person praying at Muqam-lbrahim (the place of Abraham by the Ka’ba) and he was saying Takbir on every bowing, rising, standing and sitting. I asked Ibn ‘Abbas (about this prayer). He admonished me saying: “Isn’t that the prayer of the Prophet?”
I prayed behind a Sheikh at Mecca and he said twenty two Takbirs (during the prayer). I told Ibn ‘Abbas that he (i.e. that Sheikh) was foolish. Ibn ‘Abbas admonished me and said, “This is the tradition of Abu-l-Qasim.” And narrated Abu Huraira: Whenever Allah’s Apostle stood for the prayer, he said Takbir on starting the prayer and then on bowing. On rising from bowing he said, “Sami’ a-l-lahu liman hamida,” and then while standing straight he used to say, “Rabbana laka-l hamd” (Al-Laith said, “(The Prophet said), ‘Walaka-l-hamd’.” He used to say Takbir on prostrating and on raising his head from prostration; again he would say Takbir on prostrating and raising his head. He would then do the same in the whole of the prayer till it was completed. On rising from the second Rak’a (after sitting for At-Tahiyyat), he used to say Takbir.
In a four rak`aat-long Salah, one must say 22 takbirs. Count yours and see if your Salah matches that of the Prophet (SAW)!