Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) related the story of the day of Badr: When the Companions took them (the polytheists) captive, the Messenger of Allah (peace and blessings be upon him) said: "O Abu Bakr, Ali and Umar (may Allah be pleased with them), what is your opinion about these captives?" Abu Bakr (may Allah be pleased with him) said: O Prophet of Allah (peace and blessings be upon him), they are our cousins and kinsfolk; I think you should take ransom from them, which will also give us strength against the disbelievers, and perhaps Allah will guide them to Islam. The Messenger of Allah (peace and blessings be upon him) said: "O Ibn al-Khattab, what is your view?" I said: By Allah, O Messenger of Allah, I do not hold Abu Bakr's view; my view is that you give us authority over them so that we strike their necks: let Ali (may Allah be pleased with him) be given authority over Aqil so that he strikes his neck, and let me strike the neck of so-and-so, a relative of mine; these are the leaders of disbelief. The Messenger of Allah (peace and blessings be upon him) liked what Abu Bakr said and did not like what I said. When I came to the Messenger of Allah (peace and blessings be upon him) the next day, he (peace and blessings be upon him) and Abu Bakr (may Allah be pleased with him) were both weeping. I said: O Messenger of Allah (peace and blessings be upon him), tell me why you and Abu Bakr are weeping. If there is cause for weeping, I will weep too; otherwise I will try to weep because of your weeping. The Messenger of Allah (peace and blessings be upon him) said: "I am weeping because of what your companions proposed to me about taking ransom. Their punishment was presented to me closer than this tree" (a tree that was near the Prophet (peace and blessings be upon him)). Allah Almighty revealed the verse: "It is not for a prophet to have captives until he has thoroughly subdued (the enemy) in the land" [Surah al-Anfal: 67] up to His words: "So eat of what you have taken as spoils, lawful and good" [Surah al-Anfal: 69]. Thus Allah made the spoils lawful for them.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب قسم الفيء والغنيمة / 12843