God says
It does not behove a prophet to keep captives unless he has unless he has battled strenuously on earth
-- Q.8:67
*I.e., as an aftermath of a war in self defense. As almost always in the Quran, an injunction addressed to the Prophet is, by implication, binding on his followers as well. Consequently the above verse lays down that no person may be taken or for any time retained in captivity unless he was taken prisoner in a just cause of war in defense of Faith or of freedom (regarding which see 2:190 the first verse in this topic two Fridays ago) ñ and that, therefore, the acquisition of a slave by ìpeacefulî means and the keeping of a slave thus acquired, is entirely prohibited: which to all practical purposes, amounts to a prohibition of slavery as a ìsocial institutionî . But with regard to captives taken in war, the Quran ordains (in 47:4) that they should be freed after the war is over.
Had it not been a decree from God that had already gone forth, there would indeed have befallen you a tremendous chastisement on account of all [the captives] you took.* -- Q.8:68
Prophet said
(Prophet) Moses, son of Imran, had asked: O my Lord! Among thy servants, who is most honorable to Thee. God said: He who pardons when he is in the position of power. -- H: Baihaqi. N: Abu Hurairah
Remember, the Prophet had also instructed that the captives of war should not be treated harshly. They should be, in fact, fed and clothed same way as the captors eat and clothe themselves!