مَا كَانَ لِنَبِيٍّ أَن يَكُونَ لَهُ أَسْرَىٰ حَتَّىٰ يُثْخِنَ فِي الْأَرْضِ ۚ تُرِيدُونَ عَرَضَ الدُّنْيَا وَاللَّهُ يُرِيدُ الْآخِرَةَ ۗ وَاللَّهُ عَزِيزٌ حَكِيمٌ
It is not for a Prophet that he should have prisoners of war (and free them with ransom) until he had made a great slaughter (among his enemies) in the land. You desire the good of this world (i.e. the money of ransom for freeing the captives), but Allah desires (for you) the Hereafter. And Allah is All-Mighty, All-Wise.
فَإِذَا لَقِيتُمُ الَّذِينَ كَفَرُوا فَضَرْبَ الرِّقَابِ حَتَّىٰ إِذَا أَثْخَنتُمُوهُمْ فَشُدُّوا الْوَثَاقَ فَإِمَّا مَنًّا بَعْدُ وَإِمَّا فِدَاءً حَتَّىٰ تَضَعَ الْحَرْبُ أَوْزَارَهَا ۚ ذَٰلِكَ وَلَوْ يَشَاءُ اللَّهُ لَانتَصَرَ مِنْهُمْ وَلَٰكِن لِّيَبْلُوَ بَعْضَكُم بِبَعْضٍ ۗ وَالَّذِينَ قُتِلُوا فِي سَبِيلِ اللَّهِ فَلَن يُضِلَّ أَعْمَالَهُمْ
So, when you meet (in fight Jihad in Allah's Cause), those who disbelieve smite at their necks till when you have killed and wounded many of them, then bind a bond firmly (on them, i.e. take them as captives). Thereafter (is the time) either for generosity (i.e. free them without ransom), or ransom (according to what benefits Islam), until the war lays down its burden. Thus [you are ordered by Allah to continue in carrying out Jihad against the disbelievers till they embrace Islam (i.e. are saved from the punishment in the Hell-fire) or at least come under your protection], but if it had been Allah's Will, He Himself could certainly have punished them (without you). But (He lets you fight), in order to test you, some with others. But those who are killed in the Way of Allah, He will never let their deeds be lost,