Sayyiduna Abu Hurayrah (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) said: "Any town that Allah and His Messenger (peace and blessings be upon him) conquer belongs to Allah and His Messenger (peace and blessings be upon him), and any town that is conquered through fighting, its fifth belongs to Allah and the Messenger (peace and blessings be upon him) and the rest belongs to those who fought for it."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 18393