There is a difference of opinion whether this Surah is Makki or Madani. However, according to the majority of commentators, it is a Makki Surah. Its subject matter also points to its being a Makki revelation.
Allah's commandment not to compromise in the matters of religion.
This Surah was not revealed to preach religious tolerance as some people of today seem to think, but was revealed in order to exonerate the Muslims from the disbelievers religion, their rites of worship, and their gods; to express their total disgust and unconcern with them; to tell them that Islam and Kufr (unbelief) had nothing in common and that there was no possibility of their ever being combined and mixed into one entity. Although it was initially addressed to the disbelieving Qureysh in response to their proposals of compromise, it is not confined to them only. Having made it a part of the Qur'an, Allah gave the Muslims the eternal teaching stating that they should exonerate themselves by word and deed from the creed of Kufr, wherever and in whatever form it may be, and that they should declare without any reservation that they cannot make any compromise with the disbelievers in matters of Faith.
Sayyiduna Khabbab says: "The Holy Prophet (pbuh) said to me; 'when you lie down in bed to sleep, recite Qul ya-ayyuhal Kafirun, this was the Prophet's own practice when he lay down to sleep.'" - (Reported by Bazzar, Tabarani, Ibn Marduyah). According to Ibn 'Abbas, the Prophet (pbuh) said to the people: "Should I tell you the word which will protect you from polytheism? It is that you should recite Qul ya-ayyuhal Kafirun when you go to bed." (Reported by Abu Ya'la, Tabarani). Sayyiduna Anas says that the Prophet said to Sayyiduna Mu'adh bin Jabal: "Recite Qul ya-ayyuhal-Kafirun at the time you go to bed, for this is immunity from polytheism." (Reported by Baihaqi in Ash-Shu'aib).
There was a time in Makkah when although a storm of opposition had arisen in the pagan society of Qureysh against the message of Islam preached by the Prophet (upon whom be peace), the Qureysh chiefs had not yet lost hope that they would reach some sort of a compromise with him. Therefore, from time to time they would visit him with different proposals of compromise so that he may accept compromise and the dispute between them may end. In this connection, different traditions have been related in the Hadith.
According to Sayyiduna Abdullah bin 'Abbas, the Qureysh proposed to the Prophet: "We shall give you so much wealth that you will become the richest man of Makkah. Further, we shall give you whichever woman you like in marriage and are prepared to follow and obey you as our leader on the condition that you will not speak ill of our gods. If you do not agree to this, we present another proposal which is to your and our advantage." When the Prophet asked what it was, they said that if he would worship their gods, Lat and Uzza, for a year, they would worship his God for the same span of time. The Holy Prophet said: "Wait awhile let me see what my Rabb commands in this regard." Thereupon this revelation came down. According to another tradition from Ibn 'Abbas, the Qureysh said to the Prophet: "O Muhammad, if you kiss our gods (idols), we shall worship your God." Thereupon, this Surah was sent down. Yet in another tradition Said bin Mina (the freed slave of Abul Bakhtari) has related that Walid bin Mughirah, As bin Wail, Aswad bin Al-Muttalib and Umayyah bin Khalaf met the Prophet (pbuh) and said to him: "O Muhammad (pbuh), let us agree that we would worship your God and you would worship our gods, and we would make you a partner in all our works. If what you have brought was better than what we possess, we would be partners in it with You, and have our share in it, and if what we possess is better than what you have brought, you would be partner in it with us and have your share of it." At this Allah sent down: Qul ya-ayyuhal-Kafirun (Ibn Jarir, Ibn Abi Hatim, Ibn Hisham also has related this incident in the Seerah).
Because of these repeated dialogue, there was a need that the Qureysh be given a definite, decisive reply so that their hope of Muhammad ( pbuh) coming to terms with them on the principle of "give and take" would be frustrated for ever.