The Quraish requested Rasulullah (sallallahu ‘alaihi wasallam) to refrain from speaking out against their idols. They further requested that if this was not possible, then they could come to a compromise where Rasulullah (sallallahu ‘alaihi wasallam) should worship their idols for one year, and they would worship his deity for the next year and so forth. When the Quraish made this proposal, the following surah was revealed:
قُلۡ یٰۤاَیُّہَا الۡکٰفِرُوۡنَ ۙ﴿۱﴾ لَاۤ اَعۡبُدُ مَا تَعۡبُدُوۡنَ ۙ﴿۲﴾ وَ لَاۤ اَنۡتُمۡ عٰبِدُوۡنَ مَاۤ اَعۡبُدُ ۚ﴿۳﴾ وَ لَاۤ اَنَا عَابِدٌ مَّا عَبَدۡتُّمۡ ۙ﴿۴﴾ وَ لَاۤ اَنۡتُمۡ عٰبِدُوۡنَ مَاۤ اَعۡبُدُ ؕ﴿۵﴾ لَکُمۡ دِیۡنُکُمۡ وَلِیَ دِیۡنِ ٪﴿۶﴾
Say! O you disbelievers! I do not worship what you worship, nor do you worship that which I worship. Neither will I worship that which you worship, nor will you worship that which I worship. For you is your religion, and for me is my religion. (Surah Kaafiroon)
Apart from Surah Kaafiroon, the following verse was also revealed:
قُلۡ اَفَغَیۡرَ اللّٰہِ تَاۡمُرُوۡٓنِّیۡۤ اَعۡبُدُ اَیُّہَا الۡجٰہِلُوۡنَ ﴿۶۴﴾ وَ لَقَدۡ اُوۡحِیَ اِلَیۡکَ وَ اِلَی الَّذِیۡنَ مِنۡ قَبۡلِکَ ۚ لَئِنۡ اَشۡرَکۡتَ لَیَحۡبَطَنَّ عَمَلُکَ وَ لَتَکُوۡنَنَّ مِنَ الۡخٰسِرِیۡنَ ﴿۶۵﴾ بَلِ اللّٰہَ فَاعۡبُدۡ وَ کُنۡ مِّنَ الشّٰکِرِیۡنَ ﴿۶۶﴾
Say (to them), “O you fools! Do you instruct me to worship anyone other than Allah?” And indeed it has been revealed to you (O Muhammed (sallallahu ‘alaihi wasallam)) and to those before you, “If you assign partners (unto Allah), your actions will certainly be rendered null and void and you will certainly be among the losers. Rather, it is Allah alone that you should worship, and you should be from among the grateful.” (Surah Zumar v. 64-66)
(Extracted from Seeratul Mustafa pg. 189-190)