The Holy Quran has clearly ruled in favour of building graves over mosques as documented in Surah Kahf (18): Verse 21:
فَقَالُوا ابْنُوا عَلَيْهِم بُنْيَانًا ۖرَّبُّهُمْ أَعْلَمُ بِهِمْ ۚ قَالَ الَّذِينَ غَلَبُوا عَلَىٰ أَمْرِهِمْ لَنَتَّخِذَنَّ عَلَيْهِم مَّسْجِدًا
And they said: Construct upon them a building. The second group said – Let us build a mosque on their graves (in the cave) (and thus seek blessings through this act). Surah Kahf (18): Verse 21
But skeptics have their own reasons for rejecting this clear verse on the subject.
To settle the matter beyond any doubt we list some of the renowned and revered Sunni scholars who have concluded that building mosques over graves is not just permissible but recommended according to Surah Kahf (18): Verse 21.
This list is by no means exhaustive.
- Ibn Kathir, student of Ibne Taymiyyah, states: When the People of the Cave went into the cave, some people near the entrance of the cave said – Build a mosque so we can worship Allah. The people who said this were Muslims. (Tafsir Tabari, Tafsir Ibn Kathir under Surah Kahf (18): Verse 21)
- Imam Ibn Hajr al-Asqalaani: In view of the fact that the Jews and Christians were taking the graves of their Prophets as their Qibla for the purpose of respect, and were paying attention towards them at the time of their prayers, their graves took the position of idols. For this reason the Muslims have been forbidden from this action. However, if someone constructs a mosque near the grave of a pious person for the purpose of seeking blessing (tabarruk) and not for prostration or paying attention towards them, he will never be included in this prohibition (as mentioned in Surah Kahf (18): Verse 21. (Ibn Hajr al-Asqalani, Fath al-Baari vol 3 pg 208)
- Imam Fakhruddeen al-Raazi: … some people said that it is better to build a mosque at the door, this proves that these people were ‘aarif (scholars) of Allah who believed worship and prayer’. (Tafsir al-Kabeer vol 5 pg 475)
- Imam Jalaal al-Deen al-Suyuti and Al-Muhalli: …Those who prevailed regarding their affair, the affair of the youths – namely the believers said – we will verily set up over them, around them, a place of worship, for prayers to be performed therein. And this indeed took place at the entrance of the cave. (Tafsir al Jalalain vol 1 pg 389)
- Qaazi Thanaullah Paanipatti: This verse proves that mosques can be made near graves of Awliyaa in order to send salutations on them; blessings are also attained through the tombs of Awliyaa. (Tafsir al-Mazhari vol 7, pg 123-124)
- Imam Bayzaawi: From this (verse of Surah Kahf) it is understood that to erect a mausoleum for the special people, i.e. saints and scholars, is permissible. (Tafsir al-Bayzaawi under Surah Kahf)
- Imam Ismail Haqqi al-Barousawi al Naqshbandi: To build over the graves of the scholars and awliyaa and saaliheen is a permissible act with the motive of making apparent the greatness of these pious people so that the people don’t take it as ordinary grave. (Tafsir Ruh al-Bayaan vol 3 under Surah Kahf)
- Imam Haakim: Those who prevailed over their affair refers to the believers of that era. (Tafsir al-Wahidi under Surah Kahf (18)
- Imam Nasafi: Those who prevailed over their affair were the Muslims who said to build over them i.e. on the door of cave a mosque so that Muslims can pray in it and seek blessings. (Tafsir al Nasafi vol 3 pg 18)
- Imam Abu Hayyan al-Andalusi: The person who told to make a building over them was a kafir woman, she suggested that a church be made to perform deeds of kufr; however the believers stopped her and made a mosque over there instead. (Tafsir Bahr al-Muheet vol 7 pg 158)
- Allamah Ibn Jawzi mentioned in his Tafsir under Surah Kahf (18): Verse 21: Ibn Qutaibah said that the interpreters of Quran have written: People who made the mosque were the king and his companions. (Tafsir-e-Zaad al-Maseer vol 5 pg 124)