This Surah takes its name from v. 9 in which the word (al-kahf) occurs.
Period of Revelation
This is the first of those Surahs which were sent down in the third stage of Prophethood at Makkah. We have already divided the life of the Holy Prophet at Makkah into four stages in the Introduction to Chapter 6. According to that division the third stage lasted from the fifth to the tenth year of Prophethood. What distinguishes this stage from the second and the fourth stages is this. During the second stage the Quraish mainly resorted to ridiculing, scoffing, threatening, tempting, raising objections and making false propaganda against the Holy Prophet and his followers in order to suppress the Islamic Movement. But during the third stage they employed the weapons of persecution, manhandling and economic pressure for the same purpose. So much so that a large number of the Muslims had to emigrate from Arabia to Habash, and those who remained behind were besieged in Shi'ib Abi Talib along with the Holy Prophet and his family. To add to their misery, a complete social and economic boycott was applied against them. The only redeeming feature was that there were two personalities, Abu Talib and Hadrat Khadijah, whose personal influence had been conducive to the support of two great families of the Quraish. However, when in the tenth year of Prophethood these two persons died, the fourth stage began with such revere persecutions as forced the Holy Prophet and all his Companions to emigrate from Makkah.
It appears from the theme of the Surah that it was revealed at the beginning of the third stage when in spite of persecutions and opposition, migration to Habash had not yet taken place. That is why the story of "Ashab-i-Kahf" (the Sleepers of the Cave) has been related to comfort and encourage the persecuted Muslims and to show them how the righteous people have been saving their Faith in the past.
Subject and Topics
This Surah was sent down in answer to the three questions which the mushriks of Makkah, in consultation with the people of the Book, had put to the Holy Prophet in order to test him. These were:
Who were "the Sleepers of the Cave"?
What is the real story of Khidr?
What do you know about Zul- Qarnain?
As these three questions and the stories involved concerned the history of the Christians and the Jews, and were unknown in Hijaz, a choice of these was made to test whether the Holy Prophet possessed any source of the knowledge of the hidden and unseen things. Allah, however, not only gave a complete answer to their questions but also employed the three stories to the disadvantage of the opponents of Islam in the conflict that was going on at that time at Makkah between Islam and unbelief.
The questioners were told that "the Sleepers of the Cave" believed in the same doctrine of Tauhid which was being put forward in the Quran and that their condition was similar to the condition of the persecuted Muslims of Makkah. On the other hand, the persecutors of the Sleepers of the Cave had behaved in the same way towards them as the disbelievers of the Quraish were behaving towards the Muslims. Besides this, the Muslims have been taught that even if a Believer is persecuted by a cruel society, he should not bow down before falsehood but emigrate from the place all alone, if need be, with trust in God. Incidentally the disbelievers of Makkah were told that the story of the Sleepers of the Cave was a clear proof of the creed of the Hereafter, for this showed that Allah has the power to resurrect anyone He wills even after a long sleep of death as He did in case of the Sleepers of the Cave.
The story of the Sleepers of the Cave has also been used to warn the chiefs of Makkah who were persecuting the small newly formed Muslim Community. At the same time, the Holy Prophet has been instructed that he should in no case make a compromise with their persecutors nor should he consider them to be more important than his poor followers. On the other hand, those chiefs have been admonished that they should not be puffed up with the transitory life of pleasure they were then enjoying but should seek after those excellences which are permanent and eternal.
The story of Khidr and Moses has been related in such a way as to supply the answer to the question of the disbelievers and to give comfort to the Believers as well. The lesson contained in this story is this: You should have full faith in the wisdom of what is happening in the Divine Factory in accordance with the will of Allah. As the reality is hidden from you, you are at a loss to understand the wisdom of what is happening, and sometimes if it appears that things are going against you, you cry out, "How and why has this happened?". The fact is that if the curtain be removed from the "unseen", you would yourselves come to know that what is happening here is for the best. Even if sometimes it appears that something is going against you, you will see that in the end it also produces some good results for you.
The same is true of the story of zul-Qarnain for it also admonishes the questioners, as if to say, "O you vain chiefs of Makkah you should learn a lesson from zul-Qarnain. Though he was a great ruler, a great conqueror and the owner of great resources, yet he always surrendered to his Creator, whereas you are rebelling against Him even though you are insignificant chieftains in comparison with him. Besides this, though zul-Qarnain built one of the strongest walls for protection, yet his real trust was in Allah and not in the 'wall'. He believed that the wall could protect him against his enemies as long as it was the will of Allah and that there would be cracks and holes in it, when it would be His will; whereas you who possess only insignificant fortified abodes and dwellings in comparison with him, consider yourselves to be permanently safe and secure against all sorts of calamities."
While the Quran turned the tables on the questioners who had tried to "expose" the Holy Prophet, in the end of the Surah the same things have been reiterated that were stated at its beginning: "Tauhid and the Hereafter are absolutely true and real and for your own good you should accept these doctrines, mend your ways in accordance with them and live in this world with this conviction that you are accountable to Allah: otherwise you shall ruin your life and all your doings shall be set at naught."