كتاب فرض الخمس
One-fifth of Booty to the Cause of Allah (Khumus)
Chapter: The statement of the Prophet saws: "Booty has been made legal for you Muslims."
بَابُ قَوْلِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «أُحِلَّتْ لَكُمُ الْغَنَائِمُ»
Sahih al-Bukhari 3124

Narrated Abu Huraira:

The Prophet (ﷺ) said, "A prophet amongst the prophets carried out a holy military expedition, so he said to his followers, 'Anyone who has married a woman and wants to consummate the marriage, and has not done so yet, should not accompany me; nor should a man who has built a house but has not completed its roof; nor a man who has sheep or shecamels and is waiting for the birth of their young ones.' So, the prophet carried out the expedition and when he reached that town at the time or nearly at the time of the `Asr prayer, he said to the sun, 'O sun! You are under Allah's Order and I am under Allah's Order O Allah! Stop it (i.e. the sun) from setting.' It was stopped till Allah made him victorious. Then he collected the booty and the fire came to burn it, but it did not burn it. He said (to his men), 'Some of you have stolen something from the booty. So one man from every tribe should give me a pledge of allegiance by shaking hands with me.' (They did so and) the hand of a man got stuck over the hand of their prophet. Then that prophet said (to the man), 'The theft has been committed by your people. So all the persons of your tribe should give me the pledge of allegiance by shaking hands with me.' The hands of two or three men got stuck over the hand of their prophet and he said, "You have committed the theft.' Then they brought a head of gold like the head of a cow and put it there, and the fire came and consumed the booty. The Prophet (ﷺ) added: Then Allah saw our weakness and disability, so he made booty legal for us."

حَدَّثَنَا مُحَمَّدُ بْنُ الْعَلاَءِ، حَدَّثَنَا ابْنُ الْمُبَارَكِ، عَنْ مَعْمَرٍ، عَنْ هَمَّامِ بْنِ مُنَبِّهٍ، عَنْ أَبِي هُرَيْرَةَ ـ رضى الله عنه ـ قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ غَزَا نَبِيٌّ مِنَ الأَنْبِيَاءِ فَقَالَ لِقَوْمِهِ لاَ يَتْبَعْنِي رَجُلٌ مَلَكَ بُضْعَ امْرَأَةٍ وَهْوَ يُرِيدُ أَنْ يَبْنِيَ بِهَا وَلَمَّا يَبْنِ بِهَا، وَلاَ أَحَدٌ بَنَى بُيُوتًا وَلَمْ يَرْفَعْ سُقُوفَهَا، وَلاَ أَحَدٌ اشْتَرَى غَنَمًا أَوْ خَلِفَاتٍ وَهْوَ يَنْتَظِرُ وِلاَدَهَا‏.‏ فَغَزَا فَدَنَا مِنَ الْقَرْيَةِ صَلاَةَ الْعَصْرِ أَوْ قَرِيبًا مِنْ ذَلِكَ فَقَالَ لِلشَّمْسِ إِنَّكِ مَأْمُورَةٌ وَأَنَا مَأْمُورٌ، اللَّهُمَّ احْبِسْهَا عَلَيْنَا‏.‏ فَحُبِسَتْ، حَتَّى فَتَحَ اللَّهُ عَلَيْهِ، فَجَمَعَ الْغَنَائِمَ، فَجَاءَتْ ـ يَعْنِي النَّارَ ـ لِتَأْكُلَهَا، فَلَمْ تَطْعَمْهَا، فَقَالَ إِنَّ فِيكُمْ غُلُولاً، فَلْيُبَايِعْنِي مِنْ كُلِّ قَبِيلَةٍ رَجُلٌ‏.‏ فَلَزِقَتْ يَدُ رَجُلٍ بِيَدِهِ فَقَالَ فِيكُمُ الْغُلُولُ‏.‏ فَلْتُبَايِعْنِي قَبِيلَتُكَ، فَلَزِقَتْ يَدُ رَجُلَيْنِ أَوْ ثَلاَثَةٍ بِيَدِهِ فَقَالَ فِيكُمُ الْغُلُولُ، فَجَاءُوا بِرَأْسٍ مِثْلِ رَأْسِ بَقَرَةٍ مِنَ الذَّهَبِ فَوَضَعُوهَا، فَجَاءَتِ النَّارُ فَأَكَلَتْهَا، ثُمَّ أَحَلَّ اللَّهُ لَنَا الْغَنَائِمَ، رَأَى ضَعْفَنَا وَعَجْزَنَا فَأَحَلَّهَا لَنَا ‏"‏‏.‏
Reference : Sahih al-Bukhari 3124
In-book reference : Book 57, Hadith 33
USC-MSA web (English) reference : Vol. 4, Book 53, Hadith 353
  (deprecated numbering scheme)