In Holy Quran, it is mentioned for the “Ashaf-e-Kahf” in Surah Al-Kahf as:
“Do you think that the people of the Cave and the Inscription (the news or the names of the people of the Cave) were a wonder among Our Signs? (Remember) when the young men fled for refuge (from their disbelieving folk) to the Cave, they said: “Our Lord! Bestow on us mercy from Yourself, and facilitate for us our affair in the right way!” Therefore We covered up their (sense of) hearing (causing them, to go in deep sleep) in the Cave for a number of years.
Then We raised them up (from their sleep), that We might test which of the two parties was best at calculating the time period that they had tarried. We narrate unto you (O Muhammad S.A.W) their story with truth: Truly! They were young men who believed in their Lord (Allah), and We increased them in guidance. And We made their hearts firm and strong (with the light of Faith in Allah and bestowed upon them patience to bear the separation of their kith and kin and dwellings, etc.) when they stood up and said: “Our Lord is the Lord of the heavens and the earth, never shall we call upon any ilah (god) other than Him; if we did, we should indeed have uttered an enormity in disbelief. These our people have taken for worship aliha (gods) other than Him (Allah). Why do they not bring for them a clear authority? 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, 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, etc.).” And you would have thought them awake, while they were asleep. And We turned them on their right and on their left sides, 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)]. 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. Likewise, We awakened them (from their long deep sleep) that they might question one another. 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, and let him find out which is the good lawful food, and bring some of that to you. And let him be careful 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.” 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.” Some) say they were three, the dog being the fourth among them; (others) say they were five, the dog being the sixth, guessing at the unseen; (yet others) say they were seven, the dog being the eighth. Say (O Muhammad S.A.W): “My Lord knows best their number; none knows them but a few.” So debate not (about their number, etc.) except with the clear proof (which We have revealed to you). And consult not any of them (people of the Scripture, Jews and Christians) about (the affair of) the people of the Cave. 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.” And they stayed in their Cave three hundred (solar) years, and add nine (for lunar years). Say: “Allah knows best how long they stayed. With Him is (the knowledge of) the unseen of the heavens and the earth.”
The explanation of this incident is different according to religious scholars. According to some opinions, Al-Raqim is the name of that place where this incident took place. Some others have declared it as a headstone that is placed on the cave as a memory of the “Ashab-e-Kahf”. This city was known as the “Pearha” and Arabic “Batra” later on. This place is situated at northern side of Arab. It is said that being a Christian was a crime in those days and that was the reason for the escape of those “Ashab-e-Kahf”.
According to Maulaana Maududi, Raqim is the name of that headstone. This incident has been narrated with different proves. The name of the city from which those people had migrated, is written as “Offs”. This was a seaport of Western Ocean of Asia. A king named “Daqius” ruled that region. He ruled over Rome for 249 to 251. The Ashab-e-Kahf awaked up in the kingdom of Thewdevsis. He had ruled over Rome for 408 to 450. In this way, the age of asleep of Ashab-e-Kahf is estimated as 169 years. When one of the members of Ashab-e-Kahf went to purchase the meal, the world was totally changed. The tradition, dress, language everything was changed. The man, who belonged to two hundred years back era, became the central point of attraction for everyone. When he presented a coin of two hundred years back currency, people got aware of the entire situation. This news spread in the whole city and people started to gather at the Cave. When Ashab-e-Kahf lay down, they actually died. Then people placed the headstone on the cave. What was the number of Ashaf-e-Kahf and for how many years they were sleeping? There are different opinions in this regard. But Quran has mentioned this incident for taking a lesson of strong belief in Allah.