Sayyiduna Abu Sa'id al-Khudri (may Allah be pleased with him) says that on the day of Hunayn the Messenger of Allah (peace and blessings be upon him) dispatched a detachment, which fought an army of the Arabs on the day of Awtas, and they were defeated. Women were taken captive who had husbands, and the Companions considered it sinful to have intercourse with them because of their husbands. So Allah revealed this verse: "And (forbidden to you are) married women, except those whom your right hands possess" [Surah al-Nisa': 24], meaning that these are lawful for you.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السير / 18299