Here Allah tells us about the story of the people of Al-Kahf in brief and general terms, then He explains it in more detail. He says:
[أَمْ
حَسِبْتَ]
(Do you think) -- O Muhammad --
[أَنَّ أَصْحَـبَ
الْكَهْفِ وَالرَّقِيمِ كَانُواْ مِنْ ءَايَـتِنَا عَجَبًا]
(that the people of Al-Kahf and Ar-Raqim were a wonder among Our signs)
meaning, their case was not something amazing compared to Our power and ability,
for the creation of the heavens and earth, the alternation of night and day and
the subjugation of the sun, moon and heavenly bodies, and other mighty signs
indicate the great power of Allah and show that He is able to do whatever He
wills. He is not incapable of doing more amazing things than the story of the
people of the Cave. Similarly, Ibn Jurayj reported Mujahid saying about,
[أَمْ حَسِبْتَ أَنَّ
أَصْحَـبَ الْكَهْفِ وَالرَّقِيمِ كَانُواْ مِنْ ءَايَـتِنَا عَجَبًا ]
(Do you think that the people of Al-Kahf and Ar-Raqim were a wonder among Our
signs) "Among Our signs are things that are more amazing than this.'' Al-`Awfi
reported that Ibn `Abbas said:
[أَمْ حَسِبْتَ أَنَّ
أَصْحَـبَ الْكَهْفِ وَالرَّقِيمِ كَانُواْ مِنْ ءَايَـتِنَا عَجَبًا ]
(Do you think that the people of Al-Kahf and Ar-Raqim were a wonder among Our
signs) "What I have given to you of knowledge, the Sunnah and the Book is far
better than the story of the people of Al-Kahf and Ar-Raqim.'' Muhammad bin
Ishaq said: "(It means) I have not shown My creatures a proof more amazing than
the story of the people of the Al-Kahf and Ar-Raqim.'' iAl-Kahf refers to a cave
in a mountain, which is where the young men sought refuge. With regard to the
word Ar-Raqim, Al-`Awfi reported from Ibn `Abbas that it is a valley near Aylah.
This was also said [in another narration] by `Atiyah Al-`Awfi and Qatadah.
Ad-Dahhak said: "As for Al-Kahf, it is a cave in the valley, and Ar-Raqim is the
name of the valley.'' Mujahid said, "Ar-Raqim refers to their buildings.''
Others said it refers to the valley in which their cave was. `Abdur-Razzaq
recorded that Ibn `Abbas said about Ar-Raqim: "Ka`b used to say that it was the
town.'' Ibn Jurayj reported that Ibn `Abbas said, "Ar-Raqim is the mountain in
which the cave was.'' Sa`id bin Jubayr said, "Ar-Raqim is a tablet of stone on
which they wrote the story of the people of the Cave, then they placed it at the
entrance to the Cave.''
[إِذْ أَوَى
الْفِتْيَةُ إِلَى الْكَهْفِ فَقَالُواْ رَبَّنَآ ءَاتِنَا مِن لَّدُنكَ رَحْمَةً
وَهَيِّىءْ لَنَا مِنْ أَمْرِنَا رَشَدًا ]
((Remember) when the young men fled for refuge to Al-Kahf. They said: "Our
Lord! Bestow on us mercy from Yourself, and facilitate for us our affair in the
right way!'') Here Allah tells us about those young men who fled from their
people for the sake of their religion, fearing persecution. So they fled taking
refuge in the cave of a mountain, where they hid from their people. When they
entered the cave, they asked Allah to show mercy and kindness towards them,
[رَبَّنَآ ءَاتِنَا
مِن لَّدُنكَ رَحْمَةً]
(Our Lord! Bestow on us mercy from Yourself,) meaning, `give us Your mercy
and conceal us from our people.'
[وَهَيِّىءْ لَنَا
مِنْ أَمْرِنَا رَشَدًا]
(and facilitate for us our affair in the right way.) means, direct our matter
well, i.e., grant us a good end. As was reported in the Hadith:
«وَمَا قَضَيْتَ
لَنَا مِنْ قَضَاءٍ فَاجْعَلْ عَاقِبَتَهُ رَشَدًا»
(Whatever You have decreed for us, make its consequences good).
[فَضَرَبْنَا عَلَى
ءَاذَانِهِمْ فِى الْكَهْفِ سِنِينَ عَدَدًا ]
(Therefore, We covered up their hearing in the cave for a number of years.)
meaning, `We caused them to sleep when they entered the cave, and they slept for
many years.'
[ثُمَّ
بَعَثْنَـهُمْ]
(Then We raised them up) from that slumber, and one of them went out with his
Dirhams (silver coins) to buy them some food, as it will be discussed in more
detail below. Allah says:
[ثُمَّ بَعَثْنَـهُمْ
لِنَعْلَمَ أَيُّ الحِزْبَيْنِ]
(Then We raised them up, that We might test which of the two parties)
meaning, the two parties who disputed about them,
[أَحْصَى لِمَا
لَبِثُواْ أَمَدًا]
(was best at calculating the time period that they tarried.) It was said that
this refers to how long they stayed in the cave.
[نَحْنُ نَقُصُّ
عَلَيْكَ نبَأَهُم بِالْحَقِّ إِنَّهُمْ فِتْيَةٌ ءَامَنُواْ بِرَبِّهِمْ
وَزِدْنَـهُمْ هُدًى - وَرَبَطْنَا عَلَى قُلُوبِهِمْ إِذْ قَامُواْ فَقَالُواْ
رَبُّنَا رَبُّ السَّمَـوَتِ وَالاٌّرْضِ لَن نَّدْعُوَاْ مِن دُونِهِ إِلـهاً
لَّقَدْ قُلْنَا إِذًا شَطَطًا - هَـؤُلاءِ قَوْمُنَا اتَّخَذْواْ مِن دُونِهِ
ءَالِهَةً لَّوْلاَ يَأْتُونَ عَلَيْهِم بِسُلْطَـنٍ بَيِّنٍ فَمَنْ أَظْلَمُ
مِمَّنِ افْتَرَى عَلَى اللَّهِ كَذِبًا - وَإِذِ اعْتَزَلْتُمُوهُمْ وَمَا
يَعْبُدُونَ إَلاَّ اللَّهَ فَأْوُواْ إِلَى الْكَهْفِ يَنْشُرْ لَكُمْ رَبُّكُم
مِّن رَّحْمَتِهِ وَيُهَيِّىءْ لَكُمْ مِّنْ أَمْرِكُمْ مِّرْفَقًا ]
(13. We narrate unto you their story with truth: Truly, they were young men
who believed in their Lord (Allah), and We increased them in guidance.) (14. And
We made their hearts firm and strong when they stood up and said: "Our Lord is
the Lord of the heavens and the earth, never shall we call upon any god other
than Him; if we did, we should indeed have uttered an enormity in disbelief.)
(15. These our people have taken for worship gods other than Him. Why do they
not bring for them a clear authority And who does more wrong than he who invents
a lie against Allah.) (16. (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.'')