Al-Anfal is an Arabic word, it means the spoils of war that are collected by Muslims in their Jihad (fighting against their enemies); the ruling on it was mentioned in the Saying of Allah, The Exalted, (which means): {They ask you, [O Muhammad], about the spoils [of war]. Say, "The [decision concerning] spoils are for Allah and the Messenger. So, fear Allah and amend that which is between you and obey Allah and His Messenger, if you should be believers.} [Quran 08:01]
Interpreters of the Quran mentioned three narrations on the reason of revelation of this verse, which are as follows:
First Narration: Muslim narrated that Sa’d said: Four verses of the Quran have been revealed about me. I found a sword (among the spoils of war). He (Sa’d) took it to the Prophet
and said: “O Messenger of Allah, bestow it upon me.” The Messenger of Allah, sallallahu ‘alayhi wa sallam said: “Place it there.” Then he stood up and the Messenger of Allah, sallallahu ‘alayhi wa sallam said to him: “Put it back to where you got it from.” (At this) he (Sa’d) said again: Messenger of Allah, bestow it upon me. The Messenger of Allah, sallallahu ‘alayhi wa sallam said: “Place it there.” Then he stood up and said: Messenger of Allah, bestow it upon me Shall I be treated like one who has no share in (the booty)? The Messenger of Allah sallallahu ‘alayhi wa sallam said: “Place it from where you got it.” At this point, the verse was revealed: {They ask you, [about the spoils of war. Say, "The [decision concerning] spoils are for Allah and the Messenger.}” [Ahmed, Abu Dawood, an-Nasaa-i, and at-Tirmithi]
Second Narration: Abu Dawood and An-Nasaa'i in As-Sunan Al-Kubra reported that Ibn ‘Abbas said that the Messenger of Allah
said on the day of Badr: “He who does such-and-such, will have such-and-such (from the spoils of war)”. He said the young men preceded and the old men remained standing by the battle flags, and they did not move from there. When the victory of Allah has come, the old men said: We were supporting you. If you had been defeated, you would have returned to us. Do not take this booty alone while we remain (deprived of it). The young men refused (to share) and said: The Messenger of Allah
has given it to us. Then Allah revealed (what means): {They ask you, [O Muhammad], about the spoils [of war]. Say, "The [decision concerning] spoils is for Allah and the Messenger.} until the saying of Allah (what means) [It is] just as when your Lord brought you out of your home [for the battle of Badr] in truth, while indeed, a party among the believers were unwilling.} [Quran 08:05] He said: “This proved good for them. Similarly obey me. I know the consequence of this better than you.” [Al-Albaani: Saheeh; this wording is Abu Dawood’s]
Third Narration: Imam Ahmed reported from Ubadah ibn As-Samit who said: We went with the Messenger of Allah
to the battle of Badr. When the two armies met, Allah defeated the enemy and some of us pursued them to defeat them and kill those who fled. While another group of us headed to the battlefield collecting the spoils of war. And another group surrounded the Messenger of Allah, to protect him so that the enemy could not attack him suddenly. When it was night and the various army groups went back to our camp, some of those who collected the spoils said, `We collected it, so no one else will have a share in it. Those who went in pursuit of the enemy said, `No, you do not have more right to it than us. We kept the enemy away from the war spoils and defeated them. Those who surrounded the Messenger of Allah to protect him said, `You do not have more right in it than us, we surrounded the Messenger of Allah
to protect him so that the enemy does not attack him suddenly, so we were busy with Him. Then the verse was revealed (which means): {They ask you, [O Muhammad], about the spoils [of war]. Say, "The [decision concerning] spoils are for Allah and the Messenger. So fear Allah and amend that which is between you and obey Allah and His Messenger}. The Messenger of Allah
divided it equally among Muslims. Allah's Messenger would give a fourth of the spoils when there was a surprise attack on the land of the enemy, and when there was a confrontation, then, a third to the people who returned. The Prophet
used to dislike the spoils of war and said “Strong fighters shall give some of their share to weak Muslim fighters.” [Ahmed]
These are the reason of the revelation of this verse, and the interpreters of the Quran had mentioned them, such as At-Tabari, Al-Baghawi, Ibn Al-‘Arabi, Ibn Attiya, Al-Qurtubi, Ibn Katheer, Ibn ‘Ashoor, and Ash-Shanqeeti.