The Messenger of Allah ﷺ said, "Whatever town you enter and remain in, your share is from it. Whatever town disobeys Allah and His Messenger, a fifth of its spoils belongs to Allah and His Messenger, and the rest is yours."
قال رسول الله ﷺ: أيما قرية أتيتموها وأقمتم فيها، فسهمكم فيها، وأيما قرية عصت الله ورسوله فإن خمسها لله ولرسوله ثم هي لكم.
Muslim narrated it in the Book of Jihad and Expeditions (1756), through two routes from Abdul-Razzaq, who said, Mamar informed us, from Hammam bin Munabbih, who said, "This is what Abu Hurairah related to us from the Messenger of Allah ﷺ," and he mentioned several hadiths, among them this one, saying, "He mentioned it."