According to Peacetv, the Holy Quran does not prohibit anyone from entering a mosque (provided they are not there to cause trouble) as it is a House of God that can and should be used for the worship of God by all. Only idolatry is prohibited in a Mosque but even then, all are welcome to visit a Mosque. This declaration against idolatry in a Mosque was to protect the Kaaba (and therefore any Mosque) and to ensure that it would remain a sanctuary for those who believe in the Oneness of God, as it was originally intended when its foundations were rebuilt by the Prophet Abraham (peace be on him) .
According to Peacetv, during the time of the Holy Prophet (may peace and blessings of Allah be upon him), after the victory over Mecca by the Muslims, even idolaters lived in the city and many others frequently visited to hold discussions with the Holy Prophet (may peace and blessings of Allah be upon him) without being subjected to any discrimination based on their faith. An incident during the life of the Holy Prophet (may peace and blessings of Allah be upon him) reveals that a deputation from a Christian tribe visited him in Medina to discuss religious affairs. When the deputation was about to leave the Mosque to hold its religious services at another location, the Holy Prophet (may peace and blessings of Allah be upon him) said: “There is no need for you to go out of the mosque, because the mosque is the place to worship one God, if you want to do so, you have every freedom of worship, and holding the services in it” . This incident has also been recorded in the biography of Ibn Hisham .
Furthermore the Holy Quran states:
“And who is more unjust than he who prohibits the name of Allah being glorified in Allah’s temples and seeks to ruin them? It was not proper for such men to enter therein except in fear. For them is disgrace in this world; and theirs shall be a great punishment in the next.” 
Holy Quran 2:115
While commenting on this verse, Hazrat Mirza Bashir-ud-Din Mahmood Ahmad, the second Caliph of the Ahmadiyya Muslim Community said in his Commentary of the Holy Quran :
“This verse constitutes a strong indictment of those who carry their religious differences to such extremes that they do not even refrain from perpetrating outrages against the places of worship belonging to other creeds. They hinder people from worshiping God in their sacred places and even go so far as to destroy their temples. Such acts of violence are denounced here in strong terms and a lesson of tolerance and broad mindedness is inculcated. The Quran recognizes for all men the free and unrestricted right to use their temples and declares that if anybody wishes to worship God in a place of worship, he should not be prevented from doing so; for a temple or a Mosque is a place dedicated to the worship of God and the person who prevents men from worshiping Him in it; in fact; contributes to its ruin and desolation. This is what Islam teaches about respect for the places of worship, and yet it has come to be condemned as an intolerant religion. Islam is indeed the first and the only religion to inculcate broad mindedness and teach respect for the religious susceptibilities of all peoples; and the Holy Prophet was the first person who carried this great and noble principle into actual practice.”
“It will be noted that the verse prescribes two punishments for those who prohibit the name of Allah being glorified in places of worship. One is disgrace in this world and the other is heavy punishment in the next. The punishment of disgrace is typical of the offence; for a person who first builds a temple or a Mosque with the object that the name of God may be remembered in it and then proceeds to prevent people from worshiping Him therein cannot but bring upon himself humiliation and disgrace in the eyes of the world. (…) Finally, it may be noted that the verse should not be understood to mean that the Quran advocates the unqualified access for all sorts of persons to all places of worship without regard to circumstances. In fact, only those who wish to use them for the specific purpose of God’s worship and have no ulterior motive are allowed.”
The Worldwide Head of the Ahmadiyya Muslim Community and Fifth Khalifa, Hazrat Mirza Masroor Ahmad (May Allah be his Helper) said :
“‘Masjid’ literally means a ‘place of worship’. It means a place where people bow down before God. In the Quran, God has said that Mosques belong to Him, meaning they are under His ownership. It may be that Mosques are physically constructed by human beings, but the doors to a true Mosque, that is, a Mosque built purely for the sake of Allah, remains open for all people who guarantee peace and security and who desire to enter for the sake of worshiping the Omnipotent God.”
“In Chapter 2, Verse 115 of the Quran, Allah says that there can be no one who is more unjust than a person who stops the name of God being proclaimed and who prevents worship in His Mosques. This is a very clear instruction that the doors of a true Mosque shall remain open for all people who desire to worship the One God. Therefore, a true Muslim can never be so cruel as to stop someone from worshiping God Almighty. If we assess the majestic teachings of Islam, then the beautiful aspects of its teachings continue to illuminate and spread light.”
He further states:
“It is impossible for a true Muslim to turn a Mosque into a place of fear and hatred and to turn people away from it. On the contrary, because the worship of God takes place within a Mosque and because it gives a message of peace and security, a Mosque is a place which draws people towards it like a magnet. Today, the world stands in great need for people of all religions, and even those who do not believe in religion, to come together. There is an urgent need for people of all races, nationalities and ethnicities to unite to a common purpose to save the world from destruction. All peace-loving people must join together to firmly stop all forms of cruelty wherever they occur. Everyone should remove all hostility, hatred and malice from their hearts, otherwise such enmities will ignite and cause the destruction of this world. The signs of a world war are rapidly appearing on the horizon and there is only one way to save ourselves from its devastating consequences and that is to beseech the One God, Who is compassionate to His creation, for His Mercy. It is my prayer that the world becomes inclined towards this, Ameen.”
- Holy Quran 2:128-130
- Ibn Hisham, I, 575-577
- Holy Quran 2:115
- Commentary of the Holy Quran by the Second Head of the Ahmadiyya Muslim Community, Hazrat Mirza Bashir-ud-Din Mahmood Ahmad, Khalifatul Masih II, chapter 2, verse 115.
- The Worldwide Head of the Ahmadiyya Muslim Community and Fifth Khalifa, Hazrat Mirza Masroor Ahmad (May Allah be his Helper), addressed a special reception held to celebrate the opening of the Baitur Rahman Mosque in Vancouver, Canada on 18th May 2013