The two-rakʿah salutation of the mosque during the sermon:
13 – The sum of the relevant evidences is that speaking while the sermon is in progress is, in general, forbidden. This rule is, however, qualified by the words that occur within the salutation prayer—namely reciting Qur’an, tasbīḥ (glorification), tashahhud (testimony of faith), and duʿāʾ (supplication). The hadiths that establish this exception are sound; therefore, anyone who enters the mosque while the khutbah is under way has no choice but to perform the two rakʿahs of greeting the mosque if he wishes to observe this emphatically recommended sunnah (sunna muʾakkada) and comply with what the proofs require. Indeed, the Prophet ﷺ ordered Sulaik al-Ghatafani, who had arrived during the sermon and sat down without praying the salutation, to stand and pray, which shows that the practice is firmly established—almost to the level of obligation.
Among the texts that specify the legitimacy of the salutation prayer is the authentic hadith: “When one of you comes [on Friday] while the imam is delivering the sermon, let him pray two rakʿahs.”¹