Greeting Muslims inside a mosque
What is the ruling for greeting those already sitting inside a mosque? Should one greet them before or after performing the two rak'as for entering the mosque?
Greeting those sitting inside a mosque
A Muslim must greet others in the mosque; this has nothing to do with performing the prayer for entering the mosque. If upon entering the mosque he finds others already present, he should greet them before performing the prayer for entering it and not postpone greeting them until he finishes the prayer. Otherwise, he is to pray and not be too particular about greeting those who are sitting at a distance from him inside the mosque.
Textual evidence from the sunnah
The Messenger of God (peace and blessings be upon him and his family) said: "A Muslim has six rights over another Muslim." "What are they, O Messenger of God?" he was asked. He replied, "Greeting him when you meet, accepting his invitation when he invites you, counseling him when he asks for your advice, invoking God's mercy upon him [tashmeet] when he sneezes, visiting him when he is ill, and following his funeral procession when he dies" (reported by Bukhari and Muslim).
And God Almighty knows best