‘Ali told that some slaves came out to God’s Messenger, i.e. on the day of al-Hudaibiya, before the peace was ratified, and their masters wrote to him saying, “We swear by God, Muhammad, that they have not gone out to you through desire for your religion, but they have done so only to fly from servitude.” Some people assured him they had spoken the truth and advised him to send them back to them, but God’s Messenger became angry and said, “I do not think you people of Quraish will cease till God sends someone to you who will cut off your heads for this.” He refused to send them back, saving they were God’s freedmen.
I was among the captives of Quraiza who were brought before the Prophet. The Companions examined us, and those who had begun to grow hair were killed, but those who had not were not killed. They uncovered my private parts and when they found that the hair had not begun to grow they put me among the captives.
The Prophet sent Khalid b. al-Walid to the B. Hadhima and he summoned them to accept Islam. When they did not express their acceptance of Islam properly but began to say, “We have changed our religion, we have changed our religion,”* Khalid began to kill them and take prisoners, and he handed a prisoner to each one of us. But when a day came when Khalid ordered each of us to kill his prisoner, I said, “I swear by God that I will not kill my prisoner and that not one of my companions will kill his prisoner till we come to the Prophet.” When we mentioned the matter to him he raised his hands and said twice, “O God, I declare myself innocent in Thy sight of what Khalid has done.”
‘Ali reported God's Messenger as saying that Gabriel came down to him and said to him, “Give them (i.e. your companions) their choice regarding the prisoners at Badr whether they should be killed or ransomed on condition that a like number of them should be killed the following year.” They replied, “We shall accept ransom and have some of us killed.”
Tirmidhi transmitted it, saying this is a gharib tradition.