Before taking refuge in the cave, the youths declared that God was the Lord of the heavens and the earth; and they would never call upon any deity other than Him.
Those who have taken other deities have done so without any clear authority and there is nothing more wicked than a person who lies about God. They discussed it amongst each other and withdrew to the cave; they knew that God would cover them with His mercy and guide them out of the ordeal they found themselves in.
And if you had been there with the sleepers in the cave you would have seen that the sun rose on their right and set on their left. All the while they lay in an open space within the cave.
This is one of God’s signs. Some are rightly guided while others are left to go astray. If you looked at the sleepers in the cave, you might have thought that they turned from one side to the other and their dog lay stretched out at the entrance to the cave.
And if you had seen them, you would have ran away filled with terror. In the same way that He put them to sleep, God woke them up.
The young sleepers in the cave began to question one another, asking, “how long have we been sleeping?” It felt like only a day or part of a day and they agreed that only God knew for sure how much time had passed.
One of them went to the town with a silver coin to look for food. The others warned him to be cautious and not disclose their whereabouts. If he was caught he would be stoned to death or worse he would be forced to change to their religion.
So God brought them to people’s attention so that everyone may know that His promises of Resurrection and the Last Hour were true.
The people who found them argued and disputed amongst themselves; and those who prevailed decided to build a house of worship over them. Those who heard the story argued about how many sleepers there were; but they guess at the unseen because only a few people have any real knowledge.
Therefore adhere to what is clear and never say that you will do something without saying God willing. If you do forget, then remember God and hope that He will guide you to even better conduct.
Some say they stayed in the cave for 300 years, others say 309; but Prophet Muhammad is told to say that only God knows exactly how long they were there. Because He is the one who knows all the secrets of the heavens and the earth. There is no protector besides God and He does not let anyone share in His rule.