It is derived from the sentence idh andhara qauma-hu bil Ahqaf-i of verse 21.
Period of Revelation
It is determined by an historical event that has been mentioned in vv. 29-32. This incident of the visit of the jinn and their going back after listening to the Qur'an had occurred, according to agreed traditions of the Hadith and biographical literature, at the time when the Holy Prophet had halted at Makkah during his return journey from Ta'if to Makkah. And according to all authentic historical traditions he had gone to Ta'if three years before the Hijrah; therefore it is determined that this Surah was sent down towards the end of the 10th year or in the early part of the 11th year of the Prophethood.
The 10th year of the Prophethood was a year of extreme persecution and distress in the Holy prophet's life. The Quraish and the other tribes had continued their boycott of the Bani Hashim and the Muslims for three years and the Holy Prophet and the people of his family and Companions lay besieged in Shi'b Abi Talib. The Quraish had blocked up this locality from every side so that no supplies of any kind could reach the besieged people. Only during the Hajj season they were allowed to come out and buy some articles of necessity. But even at that time whenever Abu Lahab noticed any of them approaching the market place or a trading caravan he would call out to the merchants exhorting them to announce forbidding rates of their articles for them, and would pledge that he himself would buy those articles so that they did not suffer any loss. This boycott which continued uninterrupted for three years had broken the back of the Muslims and the Bani Hashim; so much so that at times they were even forced to eat grass and the leaves of trees.
At last, when the siege was lifted this year, Abu Talib, the Holy Prophet's uncle, who had been shielding him for ten long years, died, and hardly a month later his wife, Hadrat Khadijah, who had been a source of peace and consolation for him ever since the beginning of the call, also passed away. Because of these tragic incidents, which closely followed each other, the Holy Prophet used to refer to this year as the year of sorrow and grief.
After the death of Hadart Khadijah and Abu Talib the disbelievers of Makkah became even bolder against the Holy Prophet. They started treating him even more harshly. So much so that it became difficult for him to step out of his house. Of these days Ibn Hisham has related the incident that a Quraish scoundrel one day threw dust at him openly in the street.
At last, the Holy Prophet left for Ta'if with the intention that he should invite the Bani Thaqif to Islam, for even if they did not accept Islam, they might at least be persuaded to allow him to work for his mission peacefully. He did not have the facility of any conveyance at that time, and traveled all the way to Ta'if on foot. According to some traditions, he had gone there alone, but according to others, he was accompanied by Zaid bin Harithah. He stayed at Ta'if for a few days, and approached each of the chiefs and nobles of the Bani Thaqif and talked to him about his mission. But not only they refused to listen to him, but plainly gave him the notice that he should leave their city, for they feared that his preaching might "spoil" their younger generation. Thus, he was compelled to leave Ta'if. When he was leaving the city, the chiefs of Thaqif set their slaves and scoundrels behind him, who went on crying at him, abusing him and petting him with stones for a long way from either side of the road till he became broken down with wounds and his shoes were filled with blood. Wearied and exhausted he took shelter in the shade of the wall of a garden outside Ta'if, and prayed:
"O God, to Thee I complain of my weakness, little resource, and lowliness before men. O Most Merciful, Thou art the Lord of the weak, and Thou art my Lord. To whom wilt Thou confide me? To one afar who will misuse me?Or to an enemy to whom Thou hast given power over me?If Thou art not angry with me I care not. Thy favor is more wide for me. I take refuge in the light of Thy countenance by which the darkness is illumined, and the things of this world and the next are rightly ordered, lest Thy anger descend upon me or Thy wrath light upon me. It is for Thee to be satisfied until Thou art well pleased. There is no power and no might save in Thee." (Ibn Hisham:A. Guillaume's Translation, p. 193).
Grieved and heart broken when he returned and reached near Qarn al-Manazil, he felt as though the sky was overcast by clouds. He looked up and saw Gabriel in front of him, who called out:"Allah has heard the way your people have responded. He has, therefore, sent this angel in charge of the mountains. You may command him as you please." Then the angel of the mountains greeted him and submitted :"If you like I would overturn the mountains from either side upon these people." The Holy Prophet replied : "No, but I expect that Allah will create from their seed those who will worship none but Allah, the One." (Bukhari, Dhikr al Mala'ikah; Muslim: Kitab al-Maghazi; Nasa'i :Al-Bauth).
After this he went to stay for a few days at Makkah, perplexed as to how he would face the people of Makkah, who, he thought, would be still further emboldened against him after hearing what had happened at Ta'if. It was here that one night when he was reciting the Qur'an in the Prayer, a group of the jinn happened to pass by and listened to the Qur'an, believed in it, and returned to their people to preach Islam. Thus, Allah gave His Prophet the good news that if the men were running away from his invitation, there were many of the jinn, who had become its believers, and they were spreading his message among their own kind.
Subject Matter and Topics
Such were the conditions when this Surah was sent down. Anyone who keeps this background in view, on the one hand, and studies this Surah, on the other, will have no doubt left in his mind that this is not at all the composition of Muhammad (upon whom be Allah's peace), but "a Revelation from the All Mighty, All Wise Allah." For nowhere in this Surah, from the beginning to the end, does one find even a tinge of the human feelings and reactions, which are naturally produced in a man who is passing through such hard conditions. Had it been the word of Muhammad (upon whom be Allah's peace) whom the occurrence of personal griefs one after the other and the countless and the recent bitter experience at Ta'if had caused extreme anguish and distress, it would have reflected in some degree the state of the mind of the man who was the subject of these afflictions and griefs. Consider the prayer that we have cited above: it contains his own language its every word is saturated with the feelings that he had at the time. But this Surah which was sent down precisely in the same period and was recited even by him under the same conditions, is absolutely free from every sign or trace of the time.
The subject matter of the Surah is to warn the disbelievers of the errors in which they were involved, and also resisted arrogantly, and were condemning the man who was trying to redeem them. They regarded the world as a useless and purposeless place where they were not answerable to anyone. They thought that invitation to Tauhid was false and stuck to the belief that their own deities were actually the associates of Allah. They were not inclined to believe that the Qur'an was the Word of the Lord of the worlds. They had a strange erroneous concept of apostleship on the basis of which they were proposing strange criteria of judging the Holy Prophet's claim to it. In their estimation one great proof of Islam's not being based on the truth was that their elders and important chiefs of the tribes and so called leaders of their nation were not accepting it and only a few young men, and some poor folks and some slaves had affirmed faith in it. They thought that Resurrection and life after death and the rewards and punishments of the Hereafter were fabrications whose occurrence was absolutely out of the question.
In this Surah each of these misconceptions has been refuted in a brief but rational way, and the disbelievers have been warned that if they would reject the invitation of the Qur'an and the Prophethood of the Prophet Muhammad (upon whom be Allah's peace) by prejudice and stubbornness instead of trying to understand its truth rationally, they would only be preparing for their own doom.
In the name of Allah, the Compassionate, the Merciful.