Allah the Almighty says:
“Or deemest thou that the People of the Cave and the Inscription are a wonder among Our portents? When the young men fled for refuge to the Cave and said: Our Lord! Give us mercy from Thy presence, and shape for us right conduct in our plight. Then We sealed up their hearing in the Cave for a number of years. And afterward We raised them up that We might know which of the two parties would best calculate the time that they had tarried. We narrate unto thee their story with truth. Lo! they were young men who believed in their Lord, and We increased them in guidance. And We made firm their hearts when they stood forth and said: Our Lord is the Lord of the heavens and the earth. We cry unto no god beside Him, for then should we utter an enormity. These, our people, have chosen (other) gods beside Him though they bring no clear warrant (vouchsafed) to them. And who doth greater wrong than he who inventeth a lie concerning Allah? And when ye withdraw from them and that which they worship except Allah, then seek refuge in the Cave; your Lord will spread for you of His mercy and will prepare for you a pillow in your plight. And thou mightest have seen the sun when it rose move away from their cave to the right, and when it set go past them on the left, and they were in the cleft thereof. That was (one) of the portents of Allah. He whom Allah guideth, he indeed is led aright, and he whom He sendeth astray, for him thou wilt not find a guiding friend. And thou wouldst have deemed them waking though they were asleep, and We caused them to turn over to the right and the left, and their dog stretching out his paws on the threshold. If thou hadst observed them closely thou hadst assuredly turned away from them in flight, and hadst been filled with awe of them. And in like manner We awakened them that they might question one another. A speaker from among them said: How long have ye tarried? They said: We have tarried a day or some part of a day, (Others) said: Your Lord best knoweth what ye have tarried. Now send one of you with this your silver coin unto the city, and let him see what food is purest there and bring you a supply thereof. Let him be courteous and let no man know of you. For they, if they should come to know of you, will stone you or turn you back to their religion; then ye will never prosper. And in like manner We disclosed them (to the people of the city) that they might know that the promise of Allah is true, and that, as for the Hour, there is no doubt concerning it. When (the people of the city) disputed of their case among themselves, they said: Build over them a building; their Lord knoweth best concerning them. Those who won their point said: We verily shall build a place of worship over them. (Some) will say: They were three, their dog the fourth, and (some) say: Five, their dog the sixth, guessing at random; and (some) say: Seven, and their dog the eighth. Say (O Muhammad): My Lord is best aware of their number. None knoweth them save a few. So contend not concerning them except with an outward contending, and ask not any of them to pronounce concerning them. And say not of anything: Lo! I shall do that tomorrow. Except if Allah will. And remember thy Lord when thou forgettest, and say: It may be that my Lord guideth me unto a nearer way of truth than this. And (it is said) they tarried in their Cave three hundred years and add nine. Say: Allah is best aware how long they tarried. His is the Invisible of the heavens and the earth. How clear of sight is He and keen of hearing! They have no protecting friend beside Him, and He maketh none to share in His government.” (Al-Kahf, 9-26)
The reason behind the revelation of these verses and those relating the story of Zul-Qarnain was cited by Muhammad Ibn Ishaq in his biography of the Prophet (Peace be upon him): that the people of Quraish sent to the Jews asking them for things to test the Prophet (Peace be upon him) with. The Jews said: ask him about a group of people who disappeared in the past and none has any knowledge about them; about a man who traveled through the land; and about Ar-Ruh (the Spirit). Thereupon, Almighty Allah revealed His Statement, (And they ask you (0 Muhammad (Peace be upon him)) concerning the Ruh (the Spirit); Say: “The Spirit is by command of my Lord, the knowledge of which is only with my Lord. And of knowledge, you (mankind) have been given only a little”) (Al-Isra, 85) and, (And they ask you about Zul-Qarnain. Say (0 Muhammad (Peace be upon him)): “I shall recite to you something of his story”) (Al-Kahf, 83) and here He says: (Do you think that the people of the Cave and “Ar-Raqim” the Inscription (the news or the names of the people of the Cave) were a wonder among Our Signs?), i.e. they are not more amazing than what We have given you of the great news, astonishing signs and gigantic wonders. However, a cave is a hole in the mountain. Mentioned Shuaib Al-Jibai: their cave was called “Haizam”. As for “Ar-Raqim”, Ibn Abbas (May Allah be pleased with him) said: I do not know what it means! Some scholars such as Ibn Jarir and others said: it is the record where their news and names are written thereafter. It was also said: it is the name of the mountain their cave was in. Shuaib Al-Jibai said: their dog was called “Himran”. However, many other things were said pertaining to this, but the knowledge thereof rests only with Allah the Almighty Who knows the best!
The fact that the Jews knew about them nullifies the claim of some interpreters that they were after Jesus (Peace be upon him) and that they were Christians. However, it is clear that their people were idol-worshippers. Many interpreters and historians said that they lived during the lifetime of a king called “Diqyanus” and that they were sons of some nobles or kings. They met on a feast day and saw the rituals their people were performing worship of the idols. At this very moment, Allah removed the veils from their hearts and they realized that their people were wrong-doers. Consequently, hey deserted the religion of their people and resorted to the worship of Allah Alone. It is also said: that each one of them when guided by Allah to the True Religion, abandoned his people and they coincidentally gathered in one place. Imam Muslim transmitted in his Sahih the following Prophetic Hadith which supports that meaning: “Abu Hurairah (May Allah be pleased with him) reported Allah’s Messenger (Peace be upon him) as saying: Souls are troops collected together and those who familiarized with each other (in the heaven from where these come) would have affinity, with one another (in the world) and those amongst them who opposed each other (in the Heaven) would also be divergent (in the world).” That, they asked one another about their affair and hence, they agreed on deserting and abandoning their people and fleeing with their true religion.
Allah the Almighty says: We narrate unto thee their story with truth. Lo! they were young men who believed in their Lord, and We increased them in guidance. And We made firm their hearts when they stood forth and said: Our Lord is the Lord of the heavens and the earth. We cry unto no god beside Him, for then should we utter an enormity. These, our people, have chosen (other) gods beside Him though they bring no clear warrant (vouchsafed) to them. And who doth greater wrong than he who inventeth a lie concerning Allah? (Al-Kahf, 13-15) “Clear authority” here means obvious evidence or proof. (And who does more wrong than he who invents a lie against Allah. (The young men said to one another): “And when you withdraw from them, and that which they worship, except Allah,) (Al-Kahf, 15, 16) i.e. when you deserted them and their idols that they used to worship others instead of Allah the Almighty.
Our Prophet Ibrahim (Peace be upon him) said: (And (remember) when Ibrahim (Abraham) said to his father and his people: “Verily, I am innocent of what you worship, except Him (i.e. Allah Alone I worship none) Who did create me; and verily He will guide me.)” (Az-Zukhruf, 26, 27)
Thus, some of these young men said: as you did desert your people’s religion, you should also desert them in body and figure so as to be safe from the possibility that their evil may touches you, (then seek refuge in the Cave,. your Lord will open a way for you from His Mercy and will make easy for you your affair (i.e. will give you what you will need of provision, dwelling)), (Al-Kahf, 16) i.e. Allah will draw on you His cover, protect you and reward you with the best of all rewards. Then, Allah described the cave to which they resorted stating that its door is to the north saying: (And you might have seen the sun, when it rose, declining to the right from their Cave, and when it set, turning away from them to the left), i.e. the sun rises on the western side of their cave, then it declines to the right side thereof. And, when it sets its rays come towards the cave from its eastern side. Here, the wisdom is that the sun enters their cave on its rising and setting in order to refresh the air from time to time. (While they lay in the midst of the Cave. That is (one) of the Ayat (proofs, evidences, signs) of Allah), i.e. their stay on this state for a very long period of time without eating and drinking is one of the Signs of Allah and a proof of His Magnificent Ability. (He whom Allah guides, he is the rightly guided, but he whom He sends astray, for him you will find no Wali (guiding friend) to lead him (to the Right Path). And you would have thought them awake, whereas they were asleep), for their eyes were open in order to be kept sound. (And We turned them on their right and on their left sides), it was said: they used to be turned from one side to the other once every year. However, the number of the turnings is known only to Allah the Almighty Who knows best!
Allah the Almighty says: (And their dog stretching forth his two forelegs at the entrance (of the Cave or in the space near to the entrance of the Cave (as a guard at the gate)), i.e. their dog which accompanied them when they abandoned their people did not enter the cave with them, instead, it stayed at the entrance stretching forth his two forelegs thereat. This is for it was highly disciplined and also as a sign of honor to them because the angels do not enter a house in which there is a dog. Thus, the dog was blessed because he was in their company. However, many tales and narrations were invented with regard to the dog’s name and color.
Scholars differed on the location of this cave. Some of them said: It is in the land of Aylah (i.e. Jerusalem). Others said: It is in the land of Ninawa. And others said: it is in the Sham (Syrian territories) which is more proper and Allah knows best!
After Allah the Almighty gave us perfect and complete description of them and made us as seeing them, He said: (Had you looked at them, you would certainly have turned back from them in flight, and would certainly have been filled with awe of them), i.e. because of the dignity and loftiness of their appearance. The addressed her is not only Prophet Muhammad (Peace be upon him) but also all mankind because it is a human nature to feel awe when seeing a magnificent or dignified thing. Then, Allah the Almighty awakened them (from their long deep sleep) after three-hundred and nine years; then a speaker from among them said: (“How long have you stayed (here)?” They said: “We have stayed (perhaps) a day or part of a day.” They said: “Your Lord (Alone) knows best how long you have stayed (here). So send one of you with this silver coin of yours to the town (the coins they had were called “Dafsus”.) And let him find out which is the good lawful food, and bring some of that to you.) i.e. to eat thereof. This is a sign of their piety and God fearing. (And let him be careful) during entering that town (and let no man know of you. For, if they come to know of you, they will stone you (to death or abuse and harm you) or turn you back to their religion; and in that case you will never be successful), i.e. if you turn back to their religion after you are saved by Allah the Almighty. All this because they thought they slept a day or part of a day, and they did not imagine to have slept for more than three-hundred years. The period in which almost everything have changed and their generation passed away and other generations inhabited the land.
Thus, when one of them went to the town to get the food, he feared that the people would recognize him, so he disguised. Instead, the town and its people found him to be a stranger and feared that he might be a spy or that he could harm them in any way. Some scholars said that he escaped from them. But, others said: he informed them with the news and took them to the cave to see his companions. When they approached the cave, he entered it and told his companions all about the period they spent sleeping in the cave and they confessed it to be the Divine Decree of Allah the Almighty. It was said: They went on sleeping; and others said: They all fell dead.
As for the people of the city, it was said that they could not see their place in the cave. Or, they could not enter the cave because of their cowardice, or feeling their lofty dignity. However, they (the people of the city) disputed among themselves about their case, some of them said: (Construct a building over them), i.e. block the cave’s gate to prevent them from getting out or anyone from touching them with harm. But, those who won their point said: that will be blessed because its nearness to these righteous and Godly people. This was common in the previous eras and periods prior to Prophet Muhammad (Peace be upon him). But, Islam rejects this deed (building places of worship over the graves of anyone even if it is a Prophet): the Prophet (Peace be upon him) said: “May Allah curse the Jews and Christians for they built the places of worship at the graves of their Prophets.” The Prophet (Peace be upon him) was warning (Muslims) against what the previous nations used to do with the graves of their pious people.
Allah the Almighty says: (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), i.e. to let the people know that resurrection is true and that there can be no doubt about the Hour if they know that these young men slept for more than three hundred years then they were awaken unchanged. So, He Who kept them in this state all that period, is capable to resurrect and give life again to the dead bodies after they undergo decomposition. Really, the believers do not doubt this in the least: (Verily, His Command, when He intends a thing, is only that He says to it, ‘Be!’ and it is!). (Ya-Sin, 82)
Then, He says: ((Some) say they were three, the dog being the fourth among them, and (others) say they were five, the dog being the sixth, guessing at the unseen, (yet others) say they were seven, and the dog being the eighth), as Allah cited the dispute of the people among themselves as to their number. He cited three sayings, the first two He refuted and the third He stated, a matter which indicates that the third is the true one. However, Allah guided His Prophet (Peace be upon him) to the good manners to be followed in such a case: that one should say “Allah knows best!”
For this, Allah the Almighty says: (My Lord knows best their number). His Statement: (None knows them but a few), from among the people. (So debate not (about their number) except with the clear proof (which We have revealed to you)), i.e. an easy debate and do not exert yourself in such matters. (And consult not any of them (people of the Scripture -Jews and Christians) about (the affair oj) the people of the Cave), as He concealed their number from the very beginning of the story, saying: (Truly they were young men who believed in their Lord (Allah)). (Al-Kahf, 13) So, if there was any benefit in mentioning their number, Allah the Almighty would certainly revealed it to us from the very beginning!
Allah the Almighty says: (And never say of anything, “I shall do such and such thing tomorrow.” Except (with the saying), “if Allah will!” And remember your Lord when you forget and say: “It may be that my Lord guides me unto a nearer way of truth than this “), this is a great and high moral lesson taught by Allah the Almighty that when anyone wishes to do something, he should say “If Allah wills”, because man cannot know what is hidden with Allah for tomorrow or for the future.
Abu Hurairah (May Allah be pleased with him) reported Allah’s Prophet (Peace be upon him) as saying that “Sulaiman lbn Dawud, the Messenger of Allah, observed: I will have an intercourse with seventy wives during the night; all of them will give birth to a male child who will fight in the cause of Allah. His companion or the angels said to him: Say, “If Allah wills.” But he (Sulaiman) did not say so, and he forgot it. And none of his wives gave birth to a child, but one who gave birth to a premature child. Allah’s Messenger (Peace be upon him) said: Had he said lnsha Allah (if Allah so willed), he would not have failed and his desire would have been materialized. ”
Allah the Almighty says: (And remember your Lord when you forget), for forgetting may be caused by the Devil, and remembering Allah gets the Devil out of one’s heart and thus he remembers what he has forgotten. (And say: “It may be that my Lord guides me unto a nearer way of truth than this”), i.e. if there were controversies and disputes about something, one should resort to Allah Who can facilitate it and make it so easy. Then, Allah the Almighty says: (And they stayed in their Cave three hundred (solar) years, adding nine), i.e. for lunar years. (Say: Allah knows best how long they stayed), i.e. if you are asked about this and you do not know exactly the answer, you should only attribute the matter to Allah the Almighty (With Him is (the knowledge on the Unseen of the heavens and the earth), i.e. He knows the Unseen and gives knowledge thereof to none but Whom He wishes from among His creatures; (How clearly He sees, and hears (everything)!), i.e. He puts everything in its proper place with His Perfect Knowledge and Justice. Then, He says: (They have no Wali (Helper, Disposer of affairs, Protector, Guide or Friend) other than Him, and He makes none to share in His Decision and His Rule), i.e. He is the only Disposer of affairs and He is the King Who rules over everything.
Allah the Almighty says: