I went to the mosque to perform prayer and found some worshippers sitting inside the mosque waiting for the prayer so I greeted them saying, "Assalaamu ‘Alaikum Wa Rahmatullaahi Wa Barakaatuh". Some of them returned the greeting while one of them objected, claiming that such an act was impermissible. He told me that I should have performed the prayer of Tahiyyat-ul-Masjid first, as it is a form of greeting to Allaah The Exalted, the Lord of all the Worlds whereas greeting worshipper is a person’s right. Indeed, the right of Allaah The Exalted should be given precedence over that of the people.
Could you please clarify this issue mentioning the evidence and references from the four schools of Fiqh? May Allaah The Exalted Reward you generously.
All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Dear questioner, you should know that performing the prayer of Tahiyyat-ul-Masjid upon entering a mosque before or after greeting people in the mosque does not justify this worshipper's objection as you have mentioned, as there is no explicit religious text in this regard.
However, it would have been better if you had performed the prayer of Tahiyyat-ul-Masjid first and then greeted the people inside the mosque. Imaam Ibn Al-Qayyim wrote about this issue in Zaad Al-Ma‘aad, "According to the Sunnah of the Prophet, sallallaahu ‘alayhi wa sallam, one should perform the prayer of Tahiyyat-ul-Masjid first before greeting people inside the mosque. Performing the prayer of Tahiyyat-ul-Masjid should be done before greeting people since it is the Right of Allaah The Exalted while greeting worshippers is the right of people. Indeed, the Right of Allaah The Exalted should be given precedence over that of people, unlike financial rights. There is a well-known difference of opinion in this regard. The difference between the two cases is that a consideration is given to people's need in the case of financial rights (while Allaah The Almighty Is Free of need). Also, it is beyond a person's ability to fulfill the financial rights of people and that of Allaah The Almighty together unlike the case with greeting in this situation.
The Companions used to do so. They would perform the prayer of Tahiyyat-ul-Masjid upon entering the mosque and then greet the Prophet, sallallaahu ‘alayhi wa sallam.
Rifaa‘ah ibn Raafi‘ said, "As we were with the Prophet, sallallaahu ‘alayhi wa sallam, in the mosque, a Bedouin entered and prayed but he did not perform the Rukoo’ and Sujood properly. Then he came and greeted the Prophet, sallallaahu ‘alayhi wa sallam, with Salaam. The Prophet, sallallaahu ‘alayhi wa sallam, greeted him back and said: “Go back and pray, for you have not prayed."
The Prophet, sallallaahu ‘alayhi wa sallam, criticized the man for not performing the prayer properly and not for not greeting the Prophet, sallallaahu ‘alayhi wa sallam, before performing the prayer of Tahiyyat-ul-Masjid.
Therefore, when a Muslim enters a mosque and there are people inside it, he has three due greetings to be offered respectively. First, he should recite the supplication of entering the mosque. It is recommended when entering a mosque to supplicate with the following supplication: “Bismillaahi wa As-Salatu wa As-Salaamu ‘Ala Rasoolillaah (i.e. In the Name of Allaah and Blessings and Peace be upon the Messenger of Allaah.)." Second, it is recommended for him to perform the two-Rak‘ah prayer of Tahiyyat-ul-Masjid. Third, he should greet the people inside the mosque." [Zaad Al-Ma‘aad V.2, P. 376]
Dear questioner, you should know that the prayer of Tahiyyat-ul-Masjid is recommended and not obligatory according to the majority of Muslim scholars.
Allaah Knows best.
You can search for fatwa through many choices