Short answer
No. A nikah is valid anywhere, at home, in a hall, an office or a mosque, as long as the offer and acceptance are made before two witnesses. Hanafi scholars say holding it in a mosque is recommended for blessing and publicity, but it is not required. The four schools agree.
Holding the nikah in a mosque is mustahabb because it helps announce the marriage, but it is not a condition. The usual rules of the mosque apply, such as no music, modest conduct, and a woman in her period not entering the prayer hall.
The four schools agree on this.
Explanation
Muslims marry wherever it is convenient. The Prophet ﷺ married couples in ordinary gatherings. In a well known hadith he married a poor Companion to a woman, with the mahr of teaching her some Quran, in the middle of a sitting with his Companions. What makes a nikah is the contract, not the building.
Why the mosque is recommended. Hanafi books list a mosque and a Friday among the recommended things for a nikah. The narration that tells people to hold weddings in mosques is weak in its chain, but its purpose is sound: a mosque nikah is public, simple and blessed. Announcing the marriage is sunnah, as the hadith about the daff shows.
- At home. Very common in South Asian and Arab families, and fully valid.
- In a hall or hotel, often with the walimah.
- At a registry office or civil ceremony, if the conditions of nikah are met. See court marriage.
- Online, with conditions. See online nikah.
A bride on her period. In the Hanafi school a woman in her period does not enter the prayer hall, but her nikah is valid at that time. The contract can be done in a side room, the mosque office or at home, with her consent passed on through her wali or a representative and witnesses. Whatever the venue, avoid music the scholars forbid and immodest mixing. See sunnahs of nikah.
The evidence
Quran, Surah An-Noor 24:32
وَأَنكِحُوا۟ ٱلْأَيَٰمَىٰ مِنكُمْ وَٱلصَّٰلِحِينَ مِنْ عِبَادِكُمْ وَإِمَآئِكُمْ ۚ إِن يَكُونُوا۟ فُقَرَآءَ يُغْنِهِمُ ٱللَّهُ مِن فَضْلِهِۦ ۗ وَٱللَّهُ وَٰسِعٌ عَلِيمٌۭ ﴿٣٢﴾
And marry the unmarried among you and the righteous among your male slaves and female slaves. If they should be poor, Allah will enrich them from His bounty, and Allah is all-Encompassing and Knowing.
Marriage is commanded without tying it to a place.
Sahih al-Bukhari 5132
Sahih... اذهب فقد زوجتكها بما معك من القرآن ...
"Go, I have married her to you for what you know of the Quran."
A nikah done simply, in an ordinary sitting.
Sunan an-Nasa'i 3369
Graded hasan... فصل ما بين الحلال والحرام الدف والصوت ...
"What separates the lawful from the unlawful is the daff and the voice."
The real aim is that the marriage is made public.
Where the ruling is recorded
- al-Durr al-Mukhtar with Radd al-Muhtar, Kitab al-Nikah, opening discussion. It is recommended to hold the nikah in a mosque and on a Friday.
- Nur al-Idah with Maraqi al-Falah, Bab al-Hayd wa al-Nifas. A woman in her period does not enter the mosque.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.