Reference: Majmoo’ Fataawa Ibn ‘Uthaymeen – Volume 12, Page 192
Question: If a person enters the masjid and the mu.adhdhin is making the adhaan, what is more preferable for him to do?
Response: It is more preferable for him to respond to the mu.adhdhin, then supplicate [after the adhaan has finished] with that which is legislated. He should then proceed to performing the two rak’ahs of tahiyyatul-masjid. However, some of the scholars have made exception for those who entered the masjid whilst the mu.adhdhin is making the second adhaan on the day of Jumu’ah. He should proceed to perform the two rak’ahs for tahiyyatul-masjid so that he can listen to the khutbah. Their reason for this is that listening to the khutbah is waajib whilst responding to the mu.adhdhin is not waajib. Therefore, adhering to that which is waajib is more befitting than adhering to that which is not waajib.