This is an inspiring story from Surah Al Kahf in the Qur'an.
The incident is set against the backdrop of a society that was deeply immersed in idol worshipping and other false beliefs. Deviation from the established pagan practices was not tolerated, and anyone caught breaching this belief system faced dire consequences, including physical torture and death.
The protagonists in this story are a small number of youths, who were reported to be the sons of rulers and noblemen. They are described as being in the stage of fityah, which is the age where boys begin to develop muscles and other physical characteristics of manhood. By today's estimate, this means that they were in their late teens or early twenties, in the physical prime of their lives: an age where most young men are indulging in the pleasures of the material and worldly life.
They were of the elite class, and accustomed to lives of comfort and luxury. Even so, they realized that their townspeople were immersed in wrongful practices by worshipping other than Allah. Unlike their elders, they recognized the truth and secretly shunned the false gods and customs that their elders upheld. For this, Allah increased their faith and guided them.
We narrate unto you (O Muhammad SAW) their story with truth: Truly! They were young men who believed in their Lord (Allah), and We increased them in guidance. (Qur'an 18:13)
Scholars relate that each year, the townspeople would assemble in a festival, during which time they would worship, offer sacrifices and prostrate to their idols. During one such event, these youths could no longer bear the situation around them. According to reports, the first of them decided to disassociate from these pagan rituals, and sat under the shade of a tree away from the revelry. Shortly after, a second youth followed suit, and another. These youths were strangers to each other, but by a wondrous synchronicity engineered by Allah, they were united.
There are certain catalysts which place people at spiritual crossroads: the moment of truth. At such turning points, souls will recognize each other be drawn to other similar souls. The mu'min will identify with another mu'min, the wrongdoer will gravitate towards other wrongdoers, and the soul of the pure hearted will be repulsed from the soul of the corrupt. There is a hadith which states that:
Souls are like recruited soldiers. Those that recognize each other will come together, and those who do not recognize each other will turn away from each other. [Muslim]
Each of the youths had originally kept their belief in Allah concealed for fear of repercussions, but within their secret assembly, they confessed their rejection of idolatry and affirmed their belief in Allah. From that day, they met regularly to worship Allah in secret. During this time, Allah strengthened their faith for the events which would unfold:
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.) (Qur'an 18:14)
Eventually, word of their activities reached the palace and they were summoned before their King. When questioned by the King, they refused to succumb to him, but instead, tried to invite the King to the path of Allah. The Qur'an relates:
"… 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." (Qur'an 18:14 – 18:15)
The King rejected their call to Islam, and punished them in the manner customary for that era. They were stripped of their fine clothing and elegant ornaments, and were given the night to "repent" from their ways.
The Escape and the Long Sleep
According to Shari'ah, it is permissible for one to seclude oneself from the people, for the sake of fleeing religious persecution and for safeguarding one’s belief in Allah. With Allah’s guidance, the youths managed to escape captivity during the course of the night. Allah guided them to the safety of a cave:
(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.)." (Qur'an 18:16)
The Qur’an also says:
(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!" (Qur'an 18:10)
The King ordered his men to give chase, but Allah concealed the youths from their sight. This is similar to an incident centuries later, when Muhammad SAW and his Companion, Abu Bakr RA hid in the cave of Thaur to escape the Quraish idolators, and Allah protected the two from the vision of their pursuers.
Once clear from the reaches of the enemy, sleep overcame the youths. Allah caused them to enter into a slumber in the narrow chamber of the cave, a miraculous sleep that lasted for centuries.
The mouth of the cave faced north, and the Qur'an describes that the sun would rise on the right and set on the left but never shone directly on them. Allah in His wisdom also caused them to turn from side to side during their sleep. Those who have tended to bedridden patients would know the importance of turning the patient from side to side to prevent bedsores and muscular atrophy,.
Even their dog achieved fame and was mentioned in the Qur’an. He had positioned himself at the threshold of the cave, similar to the post of a guard dog, stretching his forelegs as he slept. There is a famous hadith stating that the angel of rahmah or mercy does not enter into a dwelling which contains dogs or images of animate beings, but in the tafsir by Ibn Kathir, he concluded that as the dog was at the entrance of the cave rather than inside it, this would not have prevented angels of mercy from entering.