The mosque has a very important place in Islam. It is the place to perform worship and it is a place for learning. Under its roof, the Muslims come together like the heart of one person. Their goal is one, their action is one and their direction in prayer is one. The great importance and honor of the mosque is indicated by the fact that it is the most beloved place to Allah. The Messenger of Allah (peace and blessings of Allah be upon him) said,
"The most beloved [pieces of land] to Allah are its mosques." 
The first mosque that was established was al-bait al-haraam (lithe inviolable house") which Allah has made the hearts of mankind yearn for. He has made it a source of blessings and guidance.
"The first House (of worship) appointed for men was that at Bakka [Makkah]; full of blessing and of guidance for all kinds of beings" (Ali-Imraan 96).
After that, other houses of Allah were built. The mosque was the first building that the Muslims considered building. When the Prophet (peace and blessings of Allah be upon him) first arrived in Madinah, the building of the mosque was one of the first matters he attended to.
Anas ibn Maalik said,
"When the Prophet (peace and blessings of Allah be upon him) came to Madinah, he stayed in the neighborhood of the Tribe of Amr ibn Auf. The Prophet (peace and blessings of Allah be upon him) stayed with them fourteen nights. Then he sent for the Tribe of al-Najjaar and they came armed with their swords. [I remember it so well that it is] as if I am looking [now] as the Prophet (peace and blessings of Allah be upon him) was sitting on his mount and Abu Bakr was riding behind him and all of the Tribe of al-Najjaar around him until he dismounted at the courtyard of Abu Ayyoob's house. He used to love to pray whenever the time of prayer came. And he would pray in the sheep's pastures. He ordered that a mosque be built. He sent for some people of the Tribe of al-Najjaar and said,
'O Tribe of al-Najjaar, tell me the price for this piece of land of yours.' They answered, 'By Allah, we do not seek any price for it except from Allah.'"
Anas also said,
"There were graves of the polytheists there. Some of it was not level and there were also date palm trees [on the land]. The Prophet (peace and blessings of Allah be upon him) ordered that the graves of the pagans be dug up and the non-level land be leveled. And the date palm trees were cut down." 
The Prophet (peace and blessings of Allah be upon him) encouraged people to build mosques. He said,
"Whoever builds a mosque for the sake of Allah, desiring by it the face of Allah, Allah will build for him a house in Paradise." 
The basic rule concerning the mosques that the Muslims build is that they are built upon piety and fear of God. If there happens to occur something in a mosque that leads one to acts of shirk, then that is an incidental occurrence that does not diminish the value of the mosque itself. Instead, one should remove that evil while the mosque remains in its place.
For that reason, the scholars differentiate between a mosque that is built upon a grave and the grave that is the place of a mosque. If the mosque was before the grave, the grave should be modified and changed. It should either be leveled or it should be dug out and removed if it were new. If the grave was before the mosque, either the mosque should be removed or the form of the grave is to be removed.  The differentiation revolves around looking at the major purpose in the building of the mosque. Perhaps the destruction of the mosque of dharaar ("of evil and harm") and its burning was due to it being a mosque that was built from its beginning on a foundation of disbelief and animosity.
The group of Shukri Mustafa went to an extreme and claimed that all existing mosques on the earth today are mosques of dharaar, with the exception of only four mosques-the Mosque of al-Haram [in Makkah), Masjid al-Aqsa [in Jerusalem), the Prophet's Mosque [in Madinah) and Masjid Quba [near Madinah). Therefore, it is not allowed to pray in any mosque other than these four. 
This thought is based upon two pillars:
(1) The necessity of accepting the fact that the Muslim societies today are jaahili societies.
(2) The conclusion, therefore, is the necessity of remaining away from these societies, in particular their mosques since they are places of worship for this jaahiliyyah. 
Their evidence for the above includes:
(1) In the story of Moses, Allah states,
"We inspired Moses and his brother with this message: Provide dwellings for your people in Egypt, make your dwellings into places of worship, and establish regular prayers, and give glad tidings to those who believe" (Yoonus 87). In his discussion of this verse, Sayyid Qutb wrote,
"That experience that Allah presents for the group of believers is supposed to be an example for them and it was not only for the Tribe of Israel. It is a purely faith-related experience. At that time, the believers had found themselves as outsiders in a jaahili society wherein the trials were widespread and the false gods were in power. The people had become evil and the environment had become rotten. Such was the case during the time of the Pharaoh  as well as during that time [of the Prophet].
Therefore, Allah guided them 'O the [following) matter"
(1) Seclude and remain away from the jaahiliyyah society with its rampant, evils and iUs-as much as Possible-while 'he pure, excellent group of believers should gather together by themselves in order '0 purify, cleanse, raise and clean themselves until their promise from Allah comes.
(2) Remain away from the jaahiliyyah places of worship. The Muslim group should use some houses as mosques so they can feel their separation from the jaahiliyyah society. Therein, they can devote themselves 'O the worship of their Lord in the proper manner. The devotion by worship in itself is a form of organization in an environment of a pure form of worship. 
His words here have some generality to them and are unrestricted by time or place. However, they were taken and applied 'O the contemporary situation because I, is an ignorant jaahili era, according to their claims, and, therefore, it is obligatory to remain away from the jaahiliyyah places of worship. 
2) Their evidence includes [their argument] that in order for a place to be truly a mosque of Allah, three conditions must be met. These conditions are not met in the mosques today save in the four mosques [mentioned earlier). These conditions are:
(a) Allah alone must be called upon therein. Their evidence for this condition is Allah's statement,
"And the places of worship are for Allah (alone), so invoke not anyone along with Allah" (al-Jinn 18).
(b) Those who attend and maintain the mosques must meet certain conditions and qualifications that are mentioned by Allah in the verse,
"The mosques of Allah shall be visited and maintained by such as believe in Allah and the Last Day, establish regular prayers, and practice regular charity, and fear none (at all) except Allah. It is they who are expected to be on true guidance" (al-Taubah 18).
Allah also says,
"(Lit is such a light) in houses, which Allah has permitted to be raised to honor; for the celebration, in them, of His name: in them is He glorified in the mornings and in the evenings, (again and again), by men whom neither traffic nor merchandise can divert from the remembrance of Allah, nor from regular prayer, nor from the practice of regular charity: their (only) fear is for the day when hearts and eyes will be transformed (in a world wholly new)" (al-Noor 36-37).
Allah also says,
"In it are men who love to be purified; and Allah loves those who make themselves pure" (al-Taubah 108). It is not permissible for us, from the outset, to call any mosque a mosque of Allah unless those who attend it meet these conditions and qualities stated in these verses above.
(c) The mosque must have been founded on the basis of piety and fear of Allah.
This is based on Allah's saying,
"Never stand forth therein. There is a mosque whose foundation was laid from the first day on piety; it is more worthy of your standing forth (for prayer) therein" (al-Taubah 108). According to their claims, a look at the mosques of today shows that they do not meet these conditions. 
Critique of Their Evidence:
First, they use as a proof the verse,
"We inspired Moses and his brother with this message: Provide dwel1ings for your people in Egypt, make your dwel1ings into places of worship, and establish regular prayers, and give glad tidings to those who believe" (Yoonus 87).
This verse was revealed to state what occurred to the Tribe of Israel when Pharaoh and his chiefs put them in dire straits.
Al-Tabari recorded from ibn Abbaas concerning the words,
"make your dwel1ings into places of worship," "They were terrified from Pharaoh and his people from praying. So it was said to them, 'Make your dwellings into places of worship.' That is, make them mosques so that you may pray therein." 
In explaining this verse, Mujaahid said,
"They would not pray except in the synagogues until they had fear of Pharaoh's people, so they were ordered to pray in their houses." 
These statements clarify that the reason they were ordered to take their houses as mosques was due to their fear and terror from the violence of Pharaoh and his chiefs. The scholars have discussed this point and have stated that the obligation of attending the congregation is dropped from the one who has reason to fear for himself. 
However, abandoning the mosques for no Shareeah justification is forbidden. Verily, prayer in congregation is obligatory upon the individual. Abu Hurairah reported that the Messenger of Allah (peace and blessings of Allah be upon him) said,
"No prayer is heavier upon the hypocrites than the Morning [Fajr} Prayer and the Night [Isha) Prayer. If the people knew what they contained, they would come to them even if they had to crawl. I considered ordering the caller to prayer to announce the beginning of the prayer and then order someone to lead the people in prayer and then I would take a torch of fire and burn [their houses down} over those who had not yet come out to the prayer." 
The verse does not say that the reason was to remain away from the jaahiliyyah places of worship. The reason was only due to fear. Hence, it is not allowed to leave the congregational prayers in the mosques except due to that reason and other similar reasons that are types of necessity.
(2) They also claim that the three conditions must be met before any place can be called a mosque from the Shareeah perspective. The refutation of their conditions may be summarized as follows:
The first condition: They say that Allah alone must be invoked in the mosque for it to be called a mosque. However, this is not proven by the verse they quote. The verse is a command to the Muslims to not associate any partner with Allah in His houses, as was the case with the People of the Book.
"'And the places of worship are for Allah (alone): so invoke not,' 0 people, 'anyone along with Allah,' do not associate anything with Him. Instead, verify His oneness and make your worship purely for him.' 
"When the Jews and Christians would go to their churches and synagogues, they would associate partners with Al1ah. So Al1ah ordered His prophet to worship Allah alone as one." 
The issue is not one related to naming. In fact, whenever a mosque is founded and made an endowment, it is called a mosque. If, in the mosque, someone other than Allah is invoked or some of the worshippers call upon a deceased person and so on, this does not make the mosque then built upon associating Partners with Allah, thereby losing its name "mosque." Instead, the sin of associating Partners with Allah fa11s only upon the One who does it.
As Allah says,
"Nor can a bearer of burdens bear another's burden" (Faatir 18).
If the simple existence of calling upon other than Al1ah in a mosque would remove the name of mosque &001 that building, then such Occurs even in the mosque of the Messenger of Allah (peace and blessings of Allah be upon him). Therein, many Muslims commit acts and make Statements of shirk. Therefore, the points not the incorrect practices that take place therein. The point is whether the mosque was founded upon shirk or not. If a mosque were built upon the grave of a "saint" or prophet, then the prayer said therein is not valid.
The Messenger of Al1ah (peace and blessings of Allah be upon him) said,
"Allah cursed the Jews and Christians for they took the graves of their prophets as mosques [places of Worship]." 
The second condition: The attributes that Allah mentions in a number of verses for those who maintain and visit His houses are not a condition for calling the mosque a mosque. It is not related to the naming of the place. It is related to the people themselves who attend the place. The verses are a testimony on their behalf Ibn Katheer said concerning the Words, "The mosques of Allah shall be visited and maintained by such as believe in Al1ah and the Last Day." "Allah is testifying to the faith of the one who visits and attends the mosques."  He mentions the hadith narrated by Abu Saeed al-Khudri in which the Messenger of Allah (peace and blessings of Allah be upon him) said,
"If you see the man frequenting the mosque, testify for him that he has faith. Allah has said, 'The mosques of Allah shall be visited and maintained by such as believe in Allah and the Last Day.", 
If one of the people who frequent the mosque does not meet those characteristics, this does not justify prohibiting praying therein.
This is because a human is not held accountable for the sins of another.
However, if the mosque were built by one of the deviant, misguided groups, such as the Qadianis  and so on, then it is obligatory to remove them from the mosque while the name of the mosque remains and it is still sanctioned to pray therein.
The Third Condition: The taqwa (piety and fear of Allah) that they state as a condition in the founding of the mosque, in order for it to be called a mosque and be prayed in, is a matter of the heart which only Allah sees. People are only ordered to judge things according to what is apparent and seen. The secret matters are left only to Allah. The mere act of building a mosque to worship Allah therein should be founded on piety.
However, Allah's words,
"There is a mosque whose foundation was laid from the first day on piety,"
are in reference to the Mosque of Quba as opposed to the mosque of dharaar (established with evil intent by the hypocrites). That mosque was founded upon piety from its first day. It is not valid, though, to pronounce that all of the mosques are mosques of dharaar. That is a statement without any evidence. The Messenger of Allah (peace and blessings of Allah be upon him) himself did not know that the mosque of the hypocrites was a mosque of dharaar until Allah informed him of that. Furthermore, the mosque of dharaar combines together a number of the goals of its founders with evil intent, as stated in the verse:
(a) It is harmful to others, that is, it is harmful to the believers.
(b) It is formed on disbelief in Allah and competing against the people of Islam. The purpose of the hypocrites was to strengthen the people of hypocrisy.
(c) It was meant to divide the believers, as the hypocrites did not want all of them to attend the mosque of Quba. Hence, it made the community of the Muslims smaller. This leads to differences of opinion, the hearts not coming together and the lack of love between them.
(d) It was a type of lookout post for those fighting Allah and His Messenger. In other words, it was set up for the purpose of one who was fighting Allah and His Messenger . That was Abu Amr al-Raahib  who met with the Romans and sought the support of their emperor against the Messenger of Allah (peace and blessings of Allah be upon him). He wrote to the people who established the mosque of dharaar and told them to build that mosque so that he would be able to pray therein if he should return. 
All of these aspects-which allowed calling the mosque of the hypocrites the mosque of dharaar and permitted its destruction-are not present in today's mosques. In fact, the mosques of today that they consider mosques of dharaar were established by the noble generations, such as the Mosque of Namrah in Arafaat, the Mosque of Khaif in Mina, the mosques of Kufah, the mosques of Damascus and so on.
In conclusion, the claim that all of the mosques of the Muslims today are mosques of dharaar save for the four mosques is a claim that has no evidence for it.
1) Recorded by Muslim.
2) Recorded by al-Bukhari, Muslim, Abu Dawood and al-Nasaa' ee.
3) Recorded by al-Bukhari, Muslim, al-Tirmidhi and Ahmad.
4) Cf., ibn Qaasim, Haashiyyah al-Raudhah, vol. 1, p. 538.
5) Cf., Rajab Mukhtaar Madkoor, al-Takfeer wa al-Hijrah Wajhan li-Wajh, p. 193.
6) Cf., Saalim al-Bahinsaawi, al-Hukum wa Qadhiyah Takfeer ai-Muslim, p. 205.
7) Firaoon is a word derived from two Egyptian words, br and au, which mean, "the greatest house." This was a description for the palace of the king. It then became the common name for the kings of Egypt from the time of the First Century B.C. There were many pharaohs but no trustworthy biographical information exists for them. Cf., al-Mausooah al-Arabiyyah al-Maisarah, p. 1290.
8) Fi Dhilaal al-Quraan, vol. 3, p. 1816
9) Cf., Saalim al-Bahinsaawi, al-Hukum wa Qadhiyyah Takfeer al-Muslzm, pp. 207-209.
10) CF., Rajab Madkoor, Al-Takfeer wa al-Hijrah Wajhan li-Wajh, pp. 193-194.
11) AI-Tabari, Jaami al-Bayaan, vol. 11, p. 153.
12) Cf., al-Shaukaani, Fath al-Qadeer, vol. 2, p. 468. Note that there is a difference of opinion concerning the meaning of this verse. Some say that it means, "Make your places of worship in the direction of the Kaabah." Others say that it means, "Make your houses facing each other." Al-Tabari says that what is stated in the text above is the strongest opinion. Cf., al-Tabari, Jaami al-Bayaan, vol. 11, pp. 153-156.
13) Cf., al-Nawawi, Raudhah al-Taalibeen, vol. I, p. 345.
14) Recorded by al-Bukhari, Muslim, Abu Dawood, al-Nasaa' ee and alTirmidhi. Cf., al-Shaukaani, Nail al-Autaar, vol. 3, p. 142.
15) Al- Tabari, Jaami al-Bayaan, vol. 29, pp. 116-117.
16) Recorded by al- Tabari, Jaami al-Bayaan, vol. 29, p. 117.
17) Recorded by al-Bukhari and Muslim.
18) Ibn Katheer, Tafseer al-Quraan al-Adheem, vol. 2, p. 340.
19) Recorded by al-Tirmidhi, Ahmad, ibn Hibbaan and al-Haakim. Al-Tirmidhi said it is a hasan hadith. The chain of the hadith is weak, as it contains Darraaj, who was Abu al-Samh, and he was weak in his hadith from Abu al-Haitham, and this is one of those narrations. AI-Uqaili declared this hadith weak, as al-Albaani quoted in Mishkaat al-Masaabeeh #723.
20) The Qadianis are a movement that began around 1900, as a plot from the English colonialists in the Indian subcontinent. Its propagator was a man named Mirza Ghulam Ahmad. He claimed that he was the Messiah, then he claimed to be a prophet, and then he finally claimed divinity. Cf., al-Mausooah al-Maisarah lil-Adyaan wa al-Madhaahib al-Muaarsirah, p. 387.
21) Cf., al-Shaukaani, Fath al-Qadeer, Vol. 2, p. 403.
22) He was Abu Aamir Amr ibn Saifi ibn Maalik ibn Umayyah, from the tribe of Aus of the Days of Jaahiliyyah of Madinah. He would mention the resurrection and the religion of the monotheists. When Islam appeared, he was envious of the Prophet (peace and blessings of Al1ah be upon him) and opposed him. He was at the Battle of Uhud on the side of the polytheists. He lived in Makkah. When Islam spread, he left to Europe where he died.
Cr., al-Alaam, vol. 5, p. 79.
23) Cf., al-Tabari, Jaami al-Bayaan, vol. 23, p. 11.