Sayyiduna Ali (may Allah be pleased with him) narrates from the Messenger of Allah (peace and blessings be upon him) that Jibril (peace and blessings be upon him) descended to him and said: "Give them, meaning your Companions, the choice regarding the prisoners of Badr: (either) kill them or take ransom, on the condition that next year the same number of them (the Muslims) will be killed." The Companions said: "(We accept) the ransom, and that (the same number) of us be killed."
Imam al-Tirmidhi (may Allah have mercy on him) narrated it through Abu Ubaydah Ahmad bin Abdullah al-Hamdani and Mahmud bin Ghaylan, and said: "This hadith is hasan gharib; we do not know it except from the narration of Ibn Abi Za'idah. Abu Usamah also narrated something similar from Hisham."
Imam al-Nasa'i (may Allah have mercy on him) narrated it through Mahmud bin Ghaylan and Muhammad bin Rafi' from Abu Dawud.
Imam Ibn Hibban (may Allah have mercy on him) narrated it through Hajib bin Musa from Abu Dawud.
I (Imam Diya al-Din al-Maqdisi, may Allah have mercy on him) say: Ibn Awn also narrated it from Ibn Sirin (may Allah have mercy on him).