Period of Revelation
The two sections of this Surah were revealed in two separate periods. The first section (vv. 1-19) is unanimously a Makki Revelation, and this is supported both by its subject matter and by the traditions of the Hadith. As for the question, in which specific period of the life at Makkah it was revealed, it is not answered by the tradition, but the internal evidence of the subject matter of this section helps to determine the period of its revelation.
First, in it the Holy Prophet (upon whom be peace) has been instructed to the effect: "Arise during the night and worship Allah so that you may develop the capability to shoulder the heavy burden of Prophethood and to discharge its responsibilities." This shows that this Command must have been given in the earliest period of the Prophethood when training was being imparted to the Holy prophet by Allah for this office.
Secondly, a Command has been given in it that the Quran be recited in the Tahajjud Prayer for half the night, or thereabout. This Command by itself points out that by that time at least so much of the Quran had been revealed as could be recited for that long.
Thirdly, in this section the Holy Prophet (upon whom be peace) has been exhorted to have patience at the excesses being committed by his opponents, and the disbelievers of Makkah have been threatened with the torment. This shows that this section was revealed at a time when the Holy Propliet (upon whom be peace) had openly started preaching Islam and the opposition to him at Makkah had grown active and strong.
About the second section (v. 20) although many of the commentators have expressed the opinion that this too was sent down at Makkah, yet some other commentators regard it as a Madani Revelation, and this same opinion is confirmed by the subject matter of this section. For it mentions fighting in the way of Allah, and obviously, there could be no question of it at Makkah; it also contains the Command to pay the obligatory zakat, and it is fully confirmed that the zakat at a specific rate and with an exemption limit (nisab) was enjoined at Madinah.
Theme and Subject Matter
In the first seven verses the Holy Prophet (upon whom be peace) has been commanded to the effect: "Prepare yourself to shoulder the responsibilities of the great Mission that has been entrusted to you; its practical form is that you should rise during the hours of night and stand up in Prayer for half the night, or for a little more or less of it."
In vv. 8-14, he has been exhorted to the effect: "Devote yourself exclusively to that God Who is the Owner of the whole universe, intrust all your affairs to Him with full satisfaction of the heart. Bear with patience whatever your opponents may utter against you. Do not be intimate with them. Leave their affair to God: He Himself will deal with them."
Then, in vv. 15-19, those of the people of Makkah, who were opposing the Holy Prophet (upon whom be peace) have been warned, so as to say: "We have sent a Messenger to you just as We sent a Messenger to the Pharaoh. Just consider what fate the Pharaoh met when he did not accept the invitation of the Messenger of Allah. Supposing that you are not punished by a torment in this world, how will you save yourselves from the punishment for disbelief on the Day of Resurrection."
This is the subject matter of the first section. The second section, according to a tradition from Hadrat Sa'id bin Jubair, was sent down ten years later, and in it the initial Command given in connection with the Tahajjud Prayer, in the beginning of the first section, was curtailed. The new Command enjoined, "Offer as much of the Tahajjud Prayer as you easily can, but what the Muslims should particularly mind and attend to is the five times obligatory Prayer a day, they should establish it regularly and punctually; they should discharge their zakat dues accurately; and they should spend their wealth with sincere intentions for the sake of Allah. In conclusion, the Muslims have been exhorted, saying: "Whatever good works you do in the world, will not go waste, but they are like the provision which a traveller sends up in advance to his permanent place of residence. Whatever good you send up from the world, you will find it with Allah, and the provision thus sent up is much better than what you will have to leave behind in the world, and with Allah you will also get a much better and richer reward than what you have actually sent up before."