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:47:4

So when you meet those who disbelieve ˹in battle˺, strike ˹their˺ necks until, when you have inflicted slaughter upon them, then secure their bonds, and either ˹confer˺ favor afterwards or ransom ˹them˺ until the war lays down its burdens. That ˹is the command˺. And if Allah had willed, He could have taken vengeance upon them ˹Himself˺, but ˹He ordered armed struggle˺ to test some of you by means of others. And those who are killed in the cause of Allah - never will He waste their deeds.  

So when you encounter ˹in battle˺ those who disbelieve, then ˹attack them with˺ a striking of the necks (fadarba’l-riqābi is a verbal noun in place of the ˹full˺ verbal construction, that is to say, fa’dribū riqābahum, ‘then strike their necks’), in other words, slay them — reference is made to the ‘striking of the necks’ because the predominant cause of being slayed is to be struck in the neck. Then, when you have made thoroughly decimated them, bind, spare them, take them captive and bind firmly, the bonds (al-wathāq is what is used to bind ˹yūthaqu˺ a captive). Thereafter either ˹set them free˺ by grace (mannan is a verbal noun in place of the ˹full˺ verbal construction), that is to say, either show them grace by setting them free unconditionally; or by ransom, ransoming them with payment or with Muslim captives, until the war, that is to say, its participants, lay down its burdens, its heavy loads of weaponry and other things, so that either the disbelievers surrender or enter into a treaty. This ˹last clause˺ constitutes the ‘purpose’ of ˹enjoining the Muslims to˺ slaying and taking captive. So ˹shall it be˺ (dhālika is the predicate of an implied subject, ˹such as˺ al-amr, ‘the ordinance’, in other words, ‘the ordinance ˹of God˺ regarding them is as mentioned’). And had God willed, He could have ˹Himself˺ taken vengeance on them, without any fighting, but, He has commanded you to ˹do˺ it, that He may test some of you by means of others, from among them, by way of battle, so that the slain among you will end up in Paradise, while those ˹slain˺ among them ˹will end up˺ in the Fire. And those who are slain (qutilū: a variant reading has qātalū, ‘those who fight’) — this verse was revealed on the day of ˹the battle of˺ Uhud, after the dead and the wounded had become numerous among the Muslims — in the way of God, He will not let their works go to waste, He will ˹not˺ render ˹them˺ void.
القرآن:٤٧:٤

فَإِذَا لَقِيتُمُ الَّذِينَ كَفَرُوا فَضَرْبَ الرِّقَابِ حَتَّىٰ إِذَا أَثْخَنْتُمُوهُمْ فَشُدُّوا الْوَثَاقَ فَإِمَّا مَنًّا بَعْدُ وَإِمَّا فِدَاءً حَتَّىٰ تَضَعَ الْحَرْبُ أَوْزَارَهَا ۚ ذَٰلِكَ وَلَوْ يَشَاءُ اللَّهُ لَانْتَصَرَ مِنْهُمْ وَلَٰكِنْ لِيَبْلُوَ بَعْضَكُمْ بِبَعْضٍ ۗ وَالَّذِينَ قُتِلُوا فِي سَبِيلِ اللَّهِ فَلَنْ يُضِلَّ أَعْمَالَهُمْ  

{فإذا لقيتم الذين كفروا فضرب الرقاب} مصدر بدل من اللفظ بفعله، أي فاضربوا رقابهم، أي اقتلوهم وعبَّر بضرب الرقاب لأن الغالب في القتل أن يكون بضرب الرقبة {حتى إذا أثخنتموهم} أكثرتم فيهم القتل {فشدوا} فأمسكوا عنهم وأسروهم وشدوا {الوثاق} ما يوثق به الأسرى {فإما منا بعد} مصدر بدل من اللفظ بفعله أي تمنون عليهم بإطلاقهم من غير شيء {وإما فداءً} تفادونهم بمال أو أسرى مسلمين {حتى تضع الحرب} أي أهلها {أوزارها} أثقالها من السلاح وغيره بأن يسلم الكفار أو يدخلوا في العهد وهذه غاية للقتل والأسر {ذلك} خبر مبتدأ مقدر، أي الأمر فيهم ما ذكر {ولو يشاء الله لانتصر منهم} بغير قتال {ولكن} أمركم به {ليبلو بعضكم ببعض} منهم في القتال فيصير من قتل منكم إلى الجنة ومنهم إلى النار {والذين قتلوا} وفي قراءة قاتلوا، الآية نزلت يوم أحد وقد فشا في المسلمين القتل والجراحات {في سبيل الله فلن يضل} يحبط {أعمالهم}.