structural:expansion
Non-Muslim inclusion

Under most interpretations of sharia, non-Muslims are permitted to enter mosques provided that they respect the place and the people inside it. A dissenting opinion and minority view is presented by followers of the Maliki school of Islamic jurisprudence, who argue that non-Muslims may not be allowed into mosques under any circumstances.

The Quran addresses the subject of non-Muslims, and particularly polytheists, in mosques in two verses in its ninth chapter, Sura At-Tawba. The seventeenth verse of the chapter prohibits those who join gods with Allah —polytheists—from maintaining mosques:

It is not for the polytheists to maintain the mosques of Allah while they openly profess disbelief. Their deeds are void, and they will be in the Fire forever.

The twenty-eighth verse of the same chapter is more specific as it only considers polytheists in the Masjid al-Haram in Mecca:

O believers! Indeed, the polytheists are ˹spiritually˺ impure, so they should not approach the Sacred Mosque after this year. If you fear poverty, Allah will enrich you out of His bounty, if He wills. Surely, Allah is All-Knowing, All-Wise.

According to Ahmad ibn Hanbal, these verses were followed to the letter at the times of Muhammad, when Jews and Christians, considered monotheists, were still allowed to Al-Masjid Al-Haram. The Umayyad caliph Umar II later forbade non-Muslims from entering mosques, and his ruling remains in practice in present-day Saudi Arabia. Today, the decision on whether non-Muslims should be allowed to enter mosques varies. With few exceptions, mosques in the Arabian Peninsula as well as Morocco do not allow entry to non-Muslims. For example, the Hassan II Mosque in Casablanca is one of only two mosques in Morocco currently open to non-Muslims.

There are many other mosques in the West and Islamic world which non-Muslims are welcome to enter. Most mosques in the United States, for example, report receiving non-Muslim visitors every month. Many mosques throughout the United States welcome non-Muslims as a sign of openness to the rest of the community as well as to encourage conversions to Islam.

In modern-day Saudi Arabia, the Grand Mosque and all of Mecca are open only to Muslims. Likewise, Al-Masjid Al-Nabawi and the city of Medina that surrounds it are also off-limits to those who do not practice Islam. For mosques in other areas, it has most commonly been taken that non-Muslims may only enter mosques if granted permission to do so by Muslims, and if they have a legitimate reason. All entrants regardless of religious affiliation are expected to respect the rules and decorum for mosques.

In modern Turkey, non-Muslim tourists are allowed to enter any mosque, but there are some strict rules. Visiting a mosque is allowed only between prayers; visitors are required to wear long trousers and not to wear shoes, women must cover their heads; visitors are not allowed to interrupt praying Muslims, especially by taking photos of them; no loud talk is allowed; and no references to other religions are allowed (no crosses on necklaces, no cross gestures, etc.) Similar rules apply to mosques in Malaysia, where larger mosques that are also tourist attractions (such as the Masjid Negara) provide robes and headscarves for visitors who are deemed inappropriately attired.

In certain times and places, non-Muslims were expected to behave a certain way in the vicinity of a mosque: in some Moroccan cities, Jews were required to remove their shoes when passing by a mosque; in 18th-century Egypt, Jews and Christians had to dismount before several mosques in veneration of their sanctity.

The association of the mosque with education remained one of its main characteristics throughout history, and the school became an indispensable appendage to the mosque. From the earliest days of Islam, the mosque was the center of the Muslim community, a place for prayer, meditation, religious instruction, political discussion, and a school. Anywhere Islam took hold, mosques were established, and basic religious and educational instruction began.