Sahih Muslim 1763
It has been narrated on the authority of `Umar b. al-Khattab who said:
When it was the day on which the Battle of Badr was fought, the Messenger of Allah (ﷺ) cast a glance at the infidels, and they were one thousand while his own Companions were three hundred and nineteen. The Prophet (ﷺ) turned (his face) towards the Qibla. Then he stretched his hands and began his supplication to his Lord: "O Allah, accomplish for me what Thou hast promised to me. O Allah, bring about what Thou hast promised to me. O Allah, if this small band of Muslims is destroyed. Thou will not be worshipped on this earth." He continued his supplication to his Lord, stretching his hands, facing the Qibla, until his mantle slipped down from his shoulders. So Abu Bakr came to him, picked up his mantle and put it on his shoulders. Then he embraced him from behind and said: Prophet of Allah, this prayer of yours to your Lord will suffice you, and He will fulfill for you what He has promised you. So Allah, the Glorious and Exalted, revealed (the Qur'anic verse): "When ye appealed to your Lord for help, He responded to your call (saying): I will help you with one thousand angels coming in succession." So Allah helped him with angels. 
Abu Zumail said that the hadith was narrated to him by Ibn `Abbas who said: While on that day a Muslim was chasing a disbeliever who was going ahead of him, he heard over him the swishing of the whip and the voice of the rider saying: Go ahead, Haizum! He glanced at the polytheist who had (now) fallen down on his back. When he looked at him (carefully he found that) there was a scar on his nose and his face was torn as if it had been lashed with a whip, and had turned green with its poison. An Ansari came to the Messenger of Allah (ﷺ) and related this (event) to him. He said: You have told the truth. This was the help from the third heaven. The Muslims that day (i.e. the day of the Battle of Badr) killed seventy persons and captured seventy. The Messenger of Allah (ﷺ) said to Abu Bakr and `Umar (Allah be pleased with them): What is your opinion about these captives? Abu Bakr said: They are our kith and kin. I think you should release them after getting from them a ransom. This will be a source of strength to us against the infidels. It is quite possible that Allah may guide them to Islam. Then the Messenger of Allah (ﷺ) said: What is your opinion, Ibn Khattab? He said: Messenger of Allah, I do not hold the same opinion as Abu Bakr. I am of the opinion that you should hand them over to us so that we may cut off their heads. Hand over `Aqil to `Ali that he may cut off his head, and hand over such and such relative to me that I may cut off his head. They are leaders of the disbelievers and veterans among them. The Messenger of Allah (ﷺ) approved the opinion of Abu Bakr and did not approve what I said. The next day when I came to the Messenger of Allah (ﷺ), I found that both he and Abu Bakr were sitting shedding tears. I said: Messenger of Allah, why are you and your Companion shedding tears? Tell me the reason. For I will weep, or I will at least pretend to weep in sympathy with you. The Messenger of Allah (ﷺ) said: I weep for what has happened to your companions for taking ransom (from the prisoners). I was shown the torture to which they were subjected. It was brought to me as close as this tree. (He pointed to a tree close to him.) Then God revealed the verse: "It is not befitting for a prophet that he should take prisoners until the force of the disbelievers has been crushed..." to the end of the verse: "so eat ye the spoils of war, (it is) lawful and pure. So Allah made booty lawful for them."
حَدَّثَنَا هَنَّادُ بْنُ السَّرِيِّ، حَدَّثَنَا ابْنُ الْمُبَارَكِ، عَنْ عِكْرِمَةَ بْنِ عَمَّارٍ، حَدَّثَنِي سِمَاكٌ، الْحَنَفِيُّ قَالَ سَمِعْتُ ابْنَ عَبَّاسٍ، يَقُولُ حَدَّثَنِي عُمَرُ بْنُ الْخَطَّابِ، قَالَ لَمَّا كَانَ يَوْمُ بَدْرٍ ح وَحَدَّثَنَا زُهَيْرُ بْنُ حَرْبٍ - وَاللَّفْظُ لَهُ - حَدَّثَنَا عُمَرُ بْنُ يُونُسَ الْحَنَفِيُّ حَدَّثَنَا عِكْرِمَةُ بْنُ عَمَّارٍ حَدَّثَنِي أَبُو زُمَيْلٍ - هُوَ سِمَاكٌ الْحَنَفِيُّ - حَدَّثَنِي عَبْدُ اللَّهِ بْنُ عَبَّاسٍ قَالَ حَدَّثَنِي عُمَرُ بْنُ الْخَطَّابِ قَالَ لَمَّا كَانَ يَوْمُ بَدْرٍ نَظَرَ رَسُولُ اللَّهِ صلى الله عليه وسلم إِلَى الْمُشْرِكِينَ وَهُمْ أَلْفٌ وَأَصْحَابُهُ ثَلاَثُمِائَةٍ وَتِسْعَةَ عَشَرَ رَجُلاً فَاسْتَقْبَلَ نَبِيُّ اللَّهِ صلى الله عليه وسلم الْقِبْلَةَ ثُمَّ مَدَّ يَدَيْهِ فَجَعَلَ يَهْتِفُ بِرَبِّهِ ‏"‏ اللَّهُمَّ أَنْجِزْ لِي مَا وَعَدْتَنِي اللَّهُمَّ آتِ مَا وَعَدْتَنِي اللَّهُمَّ إِنْ تَهْلِكْ هَذِهِ الْعِصَابَةُ مِنْ أَهْلِ الإِسْلاَمِ لاَ تُعْبَدْ فِي الأَرْضِ ‏"‏ ‏.‏ فَمَازَالَ يَهْتِفُ بِرَبِّهِ مَادًّا يَدَيْهِ مُسْتَقْبِلَ الْقِبْلَةِ حَتَّى سَقَطَ رِدَاؤُهُ عَنْ مَنْكِبَيْهِ فَأَتَاهُ أَبُو بَكْرٍ فَأَخَذَ رِدَاءَهُ فَأَلْقَاهُ عَلَى مَنْكِبَيْهِ ثُمَّ الْتَزَمَهُ مِنْ وَرَائِهِ ‏.‏ وَقَالَ يَا نَبِيَّ اللَّهِ كَذَاكَ مُنَاشَدَتُكَ رَبَّكَ فَإِنَّهُ سَيُنْجِزُ لَكَ مَا وَعَدَكَ فَأَنْزَلَ اللَّهُ عَزَّ وَجَلَّ ‏{‏ إِذْ تَسْتَغِيثُونَ رَبَّكُمْ فَاسْتَجَابَ لَكُمْ أَنِّي مُمِدُّكُمْ بِأَلْفٍ مِنَ الْمَلاَئِكَةِ مُرْدِفِينَ‏}‏ فَأَمَدَّهُ اللَّهُ بِالْمَلاَئِكَةِ ‏.‏ قَالَ أَبُو زُمَيْلٍ فَحَدَّثَنِي ابْنُ عَبَّاسٍ قَالَ بَيْنَمَا رَجُلٌ مِنَ الْمُسْلِمِينَ يَوْمَئِذٍ يَشْتَدُّ فِي أَثَرِ رَجُلٍ مِنَ الْمُشْرِكِينَ أَمَامَهُ إِذْ سَمِعَ ضَرْبَةً بِالسَّوْطِ فَوْقَهُ وَصَوْتَ الْفَارِسِ يَقُولُ أَقْدِمْ حَيْزُومُ ‏.‏ فَنَظَرَ إِلَى الْمُشْرِكِ أَمَامَهُ فَخَرَّ مُسْتَلْقِيًا فَنَظَرَ إِلَيْهِ فَإِذَا هُوَ قَدْ خُطِمَ أَنْفُهُ وَشُقَّ وَجْهُهُ كَضَرْبَةِ السَّوْطِ فَاخْضَرَّ ذَلِكَ أَجْمَعُ ‏.‏ فَجَاءَ الأَنْصَارِيُّ فَحَدَّثَ بِذَلِكَ رَسُولَ اللَّهِ صلى الله عليه وسلم فَقَالَ ‏"‏ صَدَقْتَ ذَلِكَ مِنْ مَدَدِ السَّمَاءِ الثَّالِثَةِ ‏"‏ ‏.‏ فَقَتَلُوا يَوْمَئِذٍ سَبْعِينَ وَأَسَرُوا سَبْعِينَ ‏.‏ قَالَ أَبُو زُمَيْلٍ قَالَ ابْنُ عَبَّاسٍ فَلَمَّا أَسَرُوا الأُسَارَى قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم لأَبِي بَكْرٍ وَعُمَرَ ‏"‏ مَا تَرَوْنَ فِي هَؤُلاَءِ الأُسَارَى ‏"‏ ‏.‏ فَقَالَ أَبُو بَكْرٍ يَا نَبِيَّ اللَّهِ هُمْ بَنُو الْعَمِّ وَالْعَشِيرَةِ أَرَى أَنْ تَأْخُذَ مِنْهُمْ فِدْيَةً فَتَكُونُ لَنَا قُوَّةً عَلَى الْكُفَّارِ فَعَسَى اللَّهُ أَنْ يَهْدِيَهُمْ لِلإِسْلاَمِ ‏.‏ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ مَا تَرَى يَا ابْنَ الْخَطَّابِ ‏"‏ ‏.‏ قُلْتُ لاَ وَاللَّهِ يَا رَسُولَ اللَّهِ مَا أَرَى الَّذِي رَأَى أَبُو بَكْرٍ وَلَكِنِّي أَرَى أَنْ تُمَكِّنَّا فَنَضْرِبَ أَعْنَاقَهُمْ فَتُمَكِّنَ عَلِيًّا مِنْ عَقِيلٍ فَيَضْرِبَ عُنُقَهُ وَتُمَكِّنِّي مِنْ فُلاَنٍ - نَسِيبًا لِعُمَرَ - فَأَضْرِبَ عُنُقَهُ فَإِنَّ هَؤُلاَءِ أَئِمَّةُ الْكُفْرِ وَصَنَادِيدُهَا فَهَوِيَ رَسُولُ اللَّهِ صلى الله عليه وسلم مَا قَالَ أَبُو بَكْرٍ وَلَمْ يَهْوَ مَا قُلْتُ فَلَمَّا كَانَ مِنَ الْغَدِ جِئْتُ فَإِذَا رَسُولُ اللَّهِ صلى الله عليه وسلم وَأَبُو بَكْرٍ قَاعِدَيْنِ يَبْكِيَانِ قُلْتُ يَا رَسُولَ اللَّهِ أَخْبِرْنِي مِنْ أَىِّ شَىْءٍ تَبْكِي أَنْتَ وَصَاحِبُكَ فَإِنْ وَجَدْتُ بُكَاءً بَكَيْتُ وَإِنْ لَمْ أَجِدْ بُكَاءً تَبَاكَيْتُ لِبُكَائِكُمَا ‏.‏ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏"‏ أَبْكِي لِلَّذِي عَرَضَ عَلَىَّ أَصْحَابُكَ مِنْ أَخْذِهِمُ الْفِدَاءَ لَقَدْ عُرِضَ عَلَىَّ عَذَابُهُمْ أَدْنَى مِنْ هَذِهِ الشَّجَرَةِ ‏"‏ ‏.‏ شَجَرَةٍ قَرِيبَةٍ مِنْ نَبِيِّ اللَّهِ صلى الله عليه وسلم ‏.‏ وَأَنْزَلَ اللَّهُ عَزَّ وَجَلَّ ‏{‏ مَا كَانَ لِنَبِيٍّ أَنْ يَكُونَ لَهُ أَسْرَى حَتَّى يُثْخِنَ فِي الأَرْضِ‏}‏ إِلَى قَوْلِهِ ‏{‏ فَكُلُوا مِمَّا غَنِمْتُمْ حَلاَلاً طَيِّبًا‏}‏ فَأَحَلَّ اللَّهُ الْغَنِيمَةَ لَهُمْ ‏.‏