Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both) narrates from Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) (most of his hadiths are from Sayyiduna Umar (may Allah be pleased with him)): On the day of Badr, he (peace and blessings be upon him) asked: "What is your opinion about these captives?" Sayyiduna Abu Bakr (may Allah be pleased with him) said: O Prophet of Allah! They are the sons of our paternal uncles, our clan and our brothers. If we take ransom from them and release them, perhaps Allah Almighty will guide them, and we will also gain financial strength against the polytheists. He (peace and blessings be upon him) asked: "O Ibn al-Khattab! What is your opinion?" I said: O Prophet of Allah! My opinion is not that of Abu Bakr (may Allah be pleased with him); rather, these are the leaders of disbelief, so strike off their heads. But the Messenger of Allah (peace and blessings be upon him) accepted the opinion of Sayyiduna Abu Bakr (may Allah be pleased with him) and did not accept mine. He (peace and blessings be upon him) took ransom from them. The next morning I went to him (peace and blessings be upon him) and saw that Sayyiduna Abu Bakr (may Allah be pleased with him) and he (peace and blessings be upon him) were sitting and weeping. I asked: O Prophet of Allah! Tell me, what has made you and Abu Bakr (may Allah be pleased with him) weep? If there is a reason to weep, I will weep too, or else I will weep because you two are weeping. He (peace and blessings be upon him) said: "Because of what your companions put forward to me (about taking ransom), your punishment was shown to me closer than this tree. Then Allah Almighty revealed the Qur'an: 'It is not fitting for a prophet to have captives until he has thoroughly subdued (the enemy) in the land. You desire the goods of this world, while Allah intends the Hereafter.' [Surah al-Anfal: 67]" (b) Ikrimah bin Ammar (may Allah have mercy on him) added something: "So eat of what you have taken as spoils, as lawful and good." [Surah al-Anfal: 69]
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 18039