(22:39-40) وَمَا لَكُمْ لَا تُقَاتِلُونَ فِي سَبِيلِ اللَّهِ وَالْمُسْتَضْعَفِينَ مِنَ الرِّجَالِ وَالنِّسَاءِ وَالْوِلْدَانِ الَّذِينَ يَقُولُونَ رَبَّنَا أَخْرِجْنَا مِنْ هَذِهِ الْقَرْيَةِ الظَّالِمِ أَهْلُهَا وَاجْعَلْ لَنَا مِنْ لَدُنْكَ وَلِيًّا وَاجْعَلْ لَنَا مِنْ لَدُنْكَ نَصِيرًا (75) What reason do you have that you should not fight in the way of Allah and the weak among men, women, and children, for those who say, “Our Lord, cause us to go forth from the town whose people are oppressors.
Give us from You a guardian and give us from You a helper.” (4:75) These holy verses entail that the reason for passing the law of fighting was originally for the sake of self-defense, especially after the polytheists, atheists, and enemies of Islam used all means of repression, persecution, oppression, transgression, pursuit, banishment from hometowns, economic and social siege, torture, and assassinations against Muslims in order to force them to give up their faith.
In addition to the last two verses, the following verse sheds light on this fact: وَقَاتِلُوا فِي سَبِيلِ اللَّهِ الَّذِينَ يُقَاتِلُونَكُمْ وَلَا تَعْتَدُوا إِنَّ اللَّهَ لَا يُحِبُّ الْمُعْتَدِينَ (190) وَاقْتُلُوهُمْ حَيْثُ ثَقِفْتُمُوهُمْ وَأَخْرِجُوهُمْ مِنْ حَيْثُ أَخْرَجُوكُمْ وَالْفِتْنَةُ أَشَدُّ مِنَ الْقَتْلِ وَلَا تُقَاتِلُوهُمْ عِنْدَ الْمَسْجِدِ الْحَرَامِ حَتَّى يُقَاتِلُوكُمْ فِيهِ فَإِنْ قَاتَلُوكُمْ فَاقْتُلُوهُمْ كَذَلِكَ جَزَاءُ الْكَافِرِينَ (191) فَإِنِ انْتَهَوْا فَإِنَّ اللَّهَ غَفُورٌ رَحِيمٌ (192) وَقَاتِلُوهُمْ حَتَّى لَا تَكُونَ فِتْنَةٌ وَيَكُونَ الدِّينُ لِلَّهِ فَإِنِ انْتَهَوْا فَلَا عُدْوَانَ إِلَّا عَلَى الظَّالِمِينَ (193) الشَّهْرُ الْحَرَامُ بِالشَّهْرِ الْحَرَامِ وَالْحُرُمَاتُ قِصَاصٌ فَمَنِ اعْتَدَى عَلَيْكُمْ فَاعْتَدُوا عَلَيْهِ بِمِثْلِ مَا اعْتَدَى عَلَيْكُمْ وَاتَّقُوا اللَّهَ وَاعْلَمُوا أَنَّ اللَّهَ مَعَ الْمُتَّقِينَ (194) Fight in the way of Allah with those who fight with you, and do not exceed the limits.
Surely, Allah does not love those who exceed the limits. Kill them wherever you find them, and drive them out from whence they drove you out. Persecution is severer than slaughter. Do not fight with them in the Sacred Mosque until they fight with you in it, but if they do fight you, then slay them. Such is the recompense of the unbelievers. But if they desist, then surely Allah is Forgiving, Merciful.