"And those who disbelieved are allies of one another," was revealed when the Prophet was commanded to fight the polytheists entirely. There were a people among the polytheists between the Messenger of Allah and Quraysh; when the Messenger of Allah would intend to target them, they would say: 'What do you want from us when we are [...] from you, and we see your fire?' The people of the Pre-Islamic era used to venerate the fire due to the sanctity of neighborhood proximity, for when they saw their fire, they considered them their neighbors. And when the polytheists would intend to target them, they would say: 'What do you want from us when we are upon your religion?' So Allah revealed: "And those who disbelieved are allies of one another," meaning: therefore, associate the polytheists [with one another].
﴿وَالَّذِينَ كَفَرُوا بَعْضُهُمْ أَوْلِيَاءُ بعضٍ﴾ نَزَلَتْ حِينَ أُمِرَ النَّبِيُّ بِقِتَالِ الْمُشْرِكِينَ كَافَّةً، وَكَانَ قَوْمٌ مِنَ الْمُشْرِكِينَ بَيْنَ رَسُولِ اللَّهِ وَبَيْنَ قُرَيْشٍ؛ فَإِذَا أَرَادَهُمْ رَسُولُ اللَّهِ قَالُوا: مَا تُرِيدُ مِنَّا وَنَحْنُ [ … ] عَنْكُمْ وَقَدْ نَرَى نَارَكُمْ؟ وَكَانَ أَهْلُ الْجَاهِلِيَّةِ يُعَظِّمُونَ النَّارَ؛ لِحُرْمَةِ قُرْبِ الْجِوَارِ؛ لأَنَّهُمْ إِذَا رَأَوْا نَارَهُمْ فَهُمْ جِيرَانُهُمْ، وَإِذَا أَرَادَهُمُ الْمُشْرِكُونَ قَالُوا: مَا تُرِيدُونَ مِنَّا وَنَحْنُ عَلَى دِينِكُمْ؟ فَأَنْزَلَ اللَّهُ: ﴿وَالَّذِينَ كَفَرُوا بَعْضُهُمْ أَوْلِيَاءُ بَعْضٍ﴾ أَيْ: فَأَلْحِقُوا الْمُشْرِكِينَ