Ibn ʿUmar relates, “We were forbidden—or he forbade us—to pray in a mushraf mosque,” that is, one conspicuously elevated and adorned. From this report the jurists ruled that praying in a gaudily painted or intricately carved mosque is even more reprehensible, for such ornamentation distracts the worshipper’s heart. It is therefore unlawful to spend the revenue of a waqf set aside for the mosque’s upkeep or needs on gilding it or adding decorative battlements.
Ibn Ḥazm went further, saying:
“Prayer does not count in any mosque erected out of boastfulness or in rivalry with another mosque when the people of the second can hear the call to prayer from the first and can reach it without hardship. It is obligatory to demolish such a mosque, and likewise every mosque built so that people may seclude themselves in it like monks, or to which the ignorant flock seeking special merit when it contains no relics of any prophet, peace be upon them.”
His last words suggest that visiting places connected to the prophets in order to pray there would be permissible. The classical scholars differed on this. The view that seems strongest to us is that one should not deliberately set out for such sites: there is no proof for it in the Quran or the Sunnah, it may lead to excess—which is forbidden—and ʿUmar (may Allah be pleased with him) explicitly prohibited it. Saʿīd ibn Manṣūr relates in his Sunan: Abū Muʿāwiyah narrated to us, al-Aʿmash narrated to us, from al-Maʿrūr ibn Suwayd, from ʿUmar (may Allah be pleased with him), who said:
“We accompanied him on the pilgrimage he performed. At the dawn prayer he recited in the first rakʿah, ‘Have you not seen how your Lord dealt with the People of the Elephant’ (105:1), and in the second, ‘For the covenants of Quraysh’ (106:1). When he returned from the pilgrimage he saw people rushing toward a mosque. He asked, ‘What is this?’ They replied, ‘A mosque in which the Messenger of Allah prayed.’ He said, ‘That is how the People of the Book before you were ruined: they turned the remnants of their prophets into places of worship. Whoever among you happens to arrive when the time for prayer is due may pray there; otherwise, let him go on his way.’”