Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:22:39

Permission ˹to fight˺ has been given to those who are being fought, because they were wronged. And indeed, Allah is competent to give them victory.  

Permission is granted to those who fight, namely, to the believers, to fight back — this was the first verse to be revealed regarding the struggle ˹in the way of God˺ (jihād), because they have been wronged, as a result of the wrong done to them by the disbelievers. And God is truly able to help them;
القرآن:٢٢:٣٩

أُذِنَ لِلَّذِينَ يُقَاتَلُونَ بِأَنَّهُمْ ظُلِمُوا ۚ وَإِنَّ اللَّهَ عَلَىٰ نَصْرِهِمْ لَقَدِيرٌ  

{أذن للذين يقاتلون} أي للمؤمنين أن يقاتلوا، وهذه أول آية نزلت في الجهاد {بأنهم} أي بسبب أنهم {ظلموا} لظلم الكافرين إياهم {وإن الله على نصرهم لقدير}.

See similar narrations below:

Collected by Ḥākim
hakim:3469Abū ʿAbdullāh al-Ṣaffār > Aḥmad b. Mihrān > Abū Nuʿaym > Sufyān > al-Aʿmash > Muslim al-Baṭīn > Saʿīd b. Jubayr > Ibn ʿAbbās

[Machine] "He used to recite it: "Permission [to fight] has been given to those who are being fought, because they were wronged. And indeed, Allah is competent to give them victory." [Quran 22:39] He said, "This is the first verse revealed concerning fighting."  

الحاكم:٣٤٦٩أَخْبَرَنَا أَبُو عَبْدِ اللَّهِ الصَّفَّارُ ثنا أَحْمَدُ بْنُ مِهْرَانَ ثنا أَبُو نُعَيْمٍ ثنا سُفْيَانُ عَنِ الْأَعْمَشِ عَنْ مُسْلِمٍ الْبَطِينِ عَنْ سَعِيدِ بْنِ جُبَيْرٍ عَنِ ابْنِ عَبَّاسٍ

أَنَّهُ كَانَ يَقْرَؤُهَا {أُذِنَ لِلَّذِينَ يُقَاتَلُونَ بِأَنَّهُمْ ظُلِمُوا وَإِنَّ اللَّهَ عَلَى نَصْرِهِمْ لَقَدِيرٌ} [الحج 39] قَالَ «هِيَ أَوَّلُ آيَةٍ نَزَلَتْ فِي الْقِتَالِ»  

هَذَا حَدِيثٌ صَحِيحٌ عَلَى شَرْطِ الشَّيْخَيْنِ وَلَمْ يُخْرِجَاهُ على شرط البخاري ومسلم