Abdullah bin Abbas (may Allah be pleased with them both) narrates from Sayyiduna Umar bin al-Khattab (may Allah be pleased with him) that on the day of Badr, he (peace and blessings be upon him) said: "What is your view about these captives?" Sayyiduna Abu Bakr al-Siddiq (may Allah be pleased with him) said: "O Prophet of Allah (peace and blessings be upon him)! They are the sons of our uncles, our clansmen and our brothers. Let us take ransom from them and release them, so that it may be a strength for us against the polytheists. Perhaps Allah will guide them to Islam, and they will become a support for us." He (peace and blessings be upon him) said: "O Ibn al-Khattab! What is your view?" I said: I do not hold the view that Abu Bakr holds. These are the leaders and chiefs of disbelief; strike their necks. But the Prophet (peace and blessings be upon him) favoured the advice of Sayyiduna Abu Bakr al-Siddiq (may Allah be pleased with him) and did not incline to my advice. He (peace and blessings be upon him) took ransom from them. The next morning I went to the Prophet (peace and blessings be upon him), and the Prophet (peace and blessings be upon him) and Sayyiduna Abu Bakr al-Siddiq (may Allah be pleased with him) were sitting and weeping. I said: "O Prophet of Allah (peace and blessings be upon him)! What has made you and your companion weep? If it is a matter for weeping, I will weep too; otherwise I will make myself weep because of your weeping." He (peace and blessings be upon him) said: "Because of the advice your companions gave, the punishment was presented to me, closer than this tree (and the tree was very near)." Then Allah revealed: "It is not for a prophet to have captives until he has thoroughly subdued (the enemy) in the land. You desire the goods of this world, but Allah desires the Hereafter; and Allah is Almighty, All-Wise." [Surah al-Anfal: 67]
Hadith Referenceالسنن الكبرى للبيهقي / كتاب آداب القاضي / 20303