Praise be to Allah.
A masjid or mosque is a place which is prepared for the purpose of offering the five daily prayers on a permanent basis and is devoted for that purpose.
A place becomes a mosque when general permission is given to pray in it, whether it is stated clearly that it is a waqf or endowment given for the sake of Allah, or it is not stated, according to the majority of scholars apart from the Shaafa‘is. See: al-Mawsoo‘ah al-Fiqhiyyah, 37/220
Ibn Qudaamah (may Allah have mercy on him) said: A waqf is valid if it is established verbally or by means of actions which indicate that, such as if a person builds a mosque and give the people permission to pray in it, or he establishes a graveyard and gives people permission to bury the dead in it, because that is the custom and it indicates that something is a waqf. So it is permissible to establish it by means of that (action), as it may also be established verbally. That is like when a person presents food to his guests. End quote from al-Kaafi, 2/250
A mosque is no longer the property of the one who establishes it, because it is a waqf, so it is not permissible for him to sell it.
There are prayer rooms (musallas) that are set up in offices and schools; these do not come under the rulings on mosques because they are not established as waqfs and as such they do not cease to be the property of their owners. Moreover, the five daily prayers are not held regularly in them in most cases.
It says in Fataawa al-Lajnah ad-Daa’imah (5/169): What is the difference between a mosque (masjid) and a prayer room (musalla)? What I mean is: Is offering the prayer to greet the mosque (tahiyat al-masjid) obligatory in a prayer room or does it not come under that ruling? Or is it mustahabb and recommended?
A mosque (masjid) is a place that has been set aside for offering the obligatory prayers on a permanent basis and is devoted for that purpose. A prayer room or prayer place (musalla) is a place that is used for prayer occasionally, such as the ‘Eid prayers, funeral (janaazah) prayers and so on, and it is not set aside as a waqf for the five daily prayers. It is not Sunnah to offer the prayer to “greet the mosque” when entering a musalla; rather it is Sunnah to offer this prayer when entering a mosque for one who wants to sit down in the mosque; he should do it before he sits down, because the Prophet (blessings and peace of Allah be upon him) said: “When one of you enters the mosque, let him not sit down until he has prayed two rak‘ahs.” Saheeh - agreed upon.
And Allah is the source of strength. May Allah send blessings and peace upon our Prophet Muhammad and his family and companions. End quote.
Shaykh ‘Abd al-‘Azeez ibn ‘Abdullah ibn Baaz, Shaykh ‘Abdullah ibn Ghadyaan, Shaykh Saalih al-Fawzaan; Shaykh ‘Abd al-‘Azeez Aal ash-Shaykh, Shaykh Bakr Abu Zayd
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) was asked about the difference between a mosque and a prayer room, and when a place may be regarded as a mosque.
He replied: With regard to the general meaning, the entire earth is a mosque because the Prophet (blessings and peace of Allah be upon him) said: “The earth has been made a place of prostration and a means of purification for me.”
With regard to the specific meaning, a mosque is a place that has been prepared for the purpose of prayer on a permanent basis and is allocated specifically for that, whether it is built of stones, mud or cement, or not. With regard to the prayer room or prayer place, it is a place that a person uses to pray in, but he does not make it a place for prayer on a permanent basis; rather he prays there if the time for prayer comes. This is not a mosque. The evidence for that is the fact that the Messenger (blessings and peace of Allah be upon him) used to offer naafil prayers in his house, and his house was not a mosque. Similarly, ‘Utbaan ibn Maalik invited him to come to his house and pray in a place that ‘Utbaan could take as a prayer room or prayer place, and that place was not a mosque. So a prayer room is a place that is used for prayer without it being set up specifically as a public mosque in which the people can pray and that is known to have been set up specifically for that purpose.
End quote from Fataawa ash-Shaykh Ibn ‘Uthaymeen, 12/394
From the above we may conclude that a mosque is a place that fulfils the following conditions:
1-It has been set aside as a waqf and is no longer the property of the one who established it
2-General permission to pray in it has been given, i.e., anyone who wants to pray in it is not to be prevented from doing so
3-It is established for the purpose of offering the five daily prayers regularly and on a permanent basis.
And Allah knows best.