Sheikh Sayyed Sabiq states in his well-known book, Fiqh As-Sunnah, in this regard: “It is a Sunnah to offer supererogatory prayers before Friday prayer until the Imam arrives. After the Imam’s arrival, one should no longer offer any prayer, except for two rak`ahs of greeting the mosque (tahiyyatul-masjid). This may be performed quickly while the khutbah is delivered unless one comes at the end of the khutbah and does not have enough time (i.e., before the actual prayer begins) to perform tahiyyatul-masjid.
The aforementioned view is adopted by Imam ash-Shafi`i, Imam Ahmad, Ishaq and many other scholars. They quote the following hadith in support of their view:
Jabir (may Allah be pleased with him) reported that a man entered the mosque while the Prophet (peace and blessings be upon him) was delivering a Friday khutbah. The Prophet asked him, “Have you offered the prayer of greeting the mosque?” The man replied, “No!” He told him, “Pray two rak`ahs.”
In another narration it is stated: “If one of you entered the mosque on the day of Friday while the Imam is delivering the khutbah, he should pray two rak`ahs and offer them quickly.” (Reported by Ahmad, Muslim, and Abu Dawud)
In another narration, it is stated: “If one of you comes to the mosque on the day of Friday and the Imam has already arrived, he should offer two rak`ahs.” (Reported by Al-Bukhari and Muslim)
Malik, al-Layth, Abu Hanifah, ath-Thawri and many other Successors are of the view that any person who enters the mosque, while the Imam is delivering the Friday khutbah, is not to perform these two rak`ahs of greeting the mosque. They say that such a person is ordered to listen to the Imam and, thus, he is to sit down.
Based on the above, it becomes crystal clear that there is a difference among scholars concerning this issue. In the light of the aforementioned views, we conclude that performing two rak`ahs in the midst of Friday khutbah is optional; one can offer them or sit down and listen to the khutbah upon entering the mosque.”