Translation of the verse 21 from Surah Al-Kahf : Number of verses 110 - - page 296 - Part 15.
And thus We made their case known to the people, that they might know that the Promise of Allah is true, and that there can be no doubt about the Hour. (Remember) when they (the people of the city) disputed among themselves about their case, they said: "Construct a building over them, their Lord knows best about them," (then) those who won their point said (most probably the disbelievers): "We verily shall build a place of worship over them."
And similarly, We caused them to be found that they [who found them] would know that the promise of Allah is truth and that of the Hour there is no doubt. [That was] when they disputed among themselves about their affair and [then] said, "Construct over them a structure. Their Lord is most knowing about them." Said those who prevailed in the matter, "We will surely take [for ourselves] over them a masjid."
(18:21) -In this way We revealed their secret to the people of the city *17 so that they should know that Allah's promise is true and that there is no doubt about (the coming of) the Hour of Resurrection. *18 (But it is a pity that instead of considering this aspect of the matter) they were at that time disputing among themselves with regard to them (the Sleepers of the Cave). Some of them said, "Let us build a wall against them, for then Lord alone knows best about them" *19 But those people who prevailed in their matter, *20 said, "We will build a place of worship as a memorial for them" *21
*17) The secret of their sleep was revealed when one of them went to Ephesus to buy food for them and offered a coin of the period of Emperor Decius. As it was a changed world, he naturally attracted attention for he was wearing a costume of 300-year old fashion and spoke a language different from that in vogue. This was because during those two centuries the language, culture, dress etc., had undergone a marked change. So the shopkeeper looked askance at him and, according to a Syriac tradition, suspected that he had dug up some ancient treasure. Accordingly, he gathered some people of his neighbourhood and they took him before the ruler. On questioning, it was discovered that he was one of those followers of Christ, who had fled the city 300 years ago to save their Faith. As most of the population had embraced Christianity, the news immediately spread throughout the city and a big crowd of the people along with the Christian Roman Ruler, arrived at the Cave. It was then that the Sleepers of the Cave came to know that they had slept for about three hundred years. So after making salutations to their Christian brothers they lay down and their souls left their bodies.
*18) According to the Syriac tradition, at the time of this occurrence, hot discussions were going on in Ephesus about Resurrection and the Hereafter. Though the people had embraced Christianity under the influence of the Roman Empire, yet traces of shirk and idolatry of the Romans and the effects of the Greek philosophy were still very powerful. So in spite of the Christian creed of the Hereafter, many people denied this, or at least were sceptical about this. To add to this the Sadducee sect of the Jews, who formed a great part of the population of the city, openly denied the Hereafter and professed to base this on the Torah. The Christian scholars, however, could not put forward any strong arguments to refute them: so much so that the reports of the polemical discussion given in Matthew, Mark and Luke, attributed to Prophet Christ, are admittedly very weak even according to the Christian scholars. (Please refer to Matthew 22: 23-33, Mark 12: 18-27, Luke 20: 27-40). That is why the disbelievers in the Hereafter were having the upper hand and even the believers were being involved in doubts about it. It was at that time that the Sleepers of the Cave were raised up and furnished an absolute proof of the life-after-death and turned the scales in favour of the believers in this dispute.
*19) It appears from the context that this was the saying of the riglfteous people from among the Christians. They were of the opinion that a wall should be raised at the entrance of the Cave in order to let the Sleepers remain in the same condition in which they were, for they argued that their Lord alone knew best about their rank and position and the reward they deserved.
*20) The people "who prevailed in their matter" were the Roman rulers and the priests of the Christian Church, who did not let the righteous Christians have their way. This was because by the middle of the fifth century, the common people, especially the orthodox among the Christians, had become fully involved in shirk and the worship of saints and tombs. They used to visit the tombs of the saints to worship them and kept the statues of Jesus, Mary and the apostles in their churches: so much so that a few years before the rising up of the Sleepers of the Cave, in 431 A.D., a great council of the representatives of the Christian World had been held in Ephesus itself, in which it was resolved that the creed of the divinity of Christ and of Mary as the mother of God, should be included in the articles of the Christian Church. If we keep in view the year 431, it becomes clear that by "those who prevailed in their matter" are meant the leaders of the Church and the officers of the government, who had the reins of the religious and political powers in their hands. In fact these were the people who were the upholders of shirk and who decided that a mausoleum should be built over the Cave of the Sleepers to make it a place of worship.
*21) It is an irony that some people among the Muslims have misconstrued this verse of the Qur'an so as to make it lawful for themselves to build mausoleums, monuments and mosques over the tombs of the righteous persons and saints. The Qur'an has, in fact, pointed out the deviation of the workers of iniquity who prevailed upon others and built a place of worship over the Cave of the Sleepers, who were indeed a Sign of Resurrection and of the life-after-death. But they abused this good opportunity and produced another means of practising shirk.
One fails to understand how anyone can deduce from this verse an argument for the legality of building mosques over the tombs of the righteous people, when the Holy Prophet has categorically prohibited this:
(1) "Allah has cursed those women who visit tombs and those people who build mosques over them and burn lights over them" (Ahmad, Tirmizi, Abu Dawud, Nasa'i, Ibn Majah).
(2) "Beware that the people, who have passed before you, made the tombs of their Prophets the places of their worship. I forbid you to do that." (Muslim)
(3) "AIIah has cursed the Jews and the Christians, for they made the tombs of their Prophets the places of their worship." (Ahmad, Bukhari, Muslim, Nasa'i).
(4) "The behaviour of those people was strange: if a righteous person from among them, died they would build a mosque over his grave and draw his pictures. They will be treated as worst criminals on the Day on Resurrection." (Ahmad, Bukhari, Muslim, Nasa'i).
Thus, it is clear from the above Sayings of the Holy Prophet that building of the places of worship over the tombs is utterly unlawful; the Qur'an has merely stated as a historical fact the sinful act of the Christian priests and the Roman rulers and has not sanctioned such a thing. Therefore no God-fearing person can turn this into an argument for building mosques over the tombs.
Incidentally, it will be worth while to cite a statement of Rev. T. Arundell who published his Discoveries in Asia Minor in 1834. He says that he had seen the remains of the Mausoleums of Mary and the Seven Sleepers on a hillock near the remains of the ancient city of Ephesus.