Abu Sirmah (may Allah be pleased with him) asked Abu Sa'id al-Khudri (may Allah be pleased with him): Did you hear the Messenger of Allah (peace and blessings be upon him) mention 'azl (coitus interruptus)? He said: Yes. We were with the Messenger of Allah (peace and blessings be upon him) in the expedition against Banu al-Mustaliq. We took noble Arab women captive, our time away from our wives grew long, and we desired the ransom, so we wished to enjoy them and practise 'azl. We said: Shall we do so while the Messenger of Allah (peace and blessings be upon him) is among us, without asking him? So we asked, and the Messenger of Allah (peace and blessings be upon him) said: "There is no harm on you if you do not do it; any soul whose creation Allah has decreed will certainly come into being, until the Day of Resurrection."
This is evidence that he (peace and blessings be upon him) divided the spoils before coming back to Madinah, as is the position of Imam al-Awza'i and Imam al-Shafi'i (may Allah have mercy on them both). Abu Yusuf (may Allah have mercy on him) says that when the Messenger of Allah (peace and blessings be upon him) conquered Banu al-Mustaliq and prevailed over them, their land became part of the abode of Islam, and he (peace and blessings be upon him) sent al-Walid bin Uqbah to collect zakah from them.
Imam al-Shafi'i (may Allah have mercy on him), refuting Abu Yusuf (may Allah have mercy on him), replied that the Messenger of Allah (peace and blessings be upon him) raided them while they were heedless among their livestock; he killed them and took them captive, and their properties and captives were divided. This was in their own land, in the year 5 AH, whereas they became Muslim a long time after that. Then he (peace and blessings be upon him) sent al-Walid bin Uqbah to collect zakah, and that was in the year 10 AH; and when he (peace and blessings be upon him) returned from them, it was still enemy territory.
The Shaykh (may Allah have mercy on him) says: It took place in the year 5 AH; so said Urwah and Ibn Shihab (may Allah have mercy on them both).
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 17973