Abdullah bin Masud reported,

We used to go on military expeditions with the Messenger of Allah ﷺ without our wives being with us, so we asked, "Should we not castrate ourselves?" He forbade us from doing so, then granted us permission to marry a woman in exchange for a garment for a fixed term.Then Abdullah recited, "You who believe, do not forbid the good things that Allah has made lawful for you, and do not transgress. Indeed, Allah does not love transgressors" [Maidah 5:87].

Muslim 3410

Sahih

حدثنا محمد بن عبد الله بن نمير الهمداني حدثنا أبي ووكيع وابن بشر عن إسمعيل عن قيس قال سمعت

عبد الله يقول

كنا نغزو مع رسول الله ﷺ ليس لنا نساء فقلنا ألا نستخصي فنهانا عن ذلك ثم رخص لنا أن ننكح المرأة بالثوب إلى أجل ثم قرأ عبد الله {يا أيها الذين آمنوا لا تحرموا طيبات ما أحل الله لكم ولا تعتدوا إن الله لا يحب المعتدين}

مسلم 3410صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Muslim
Book
Marriage
Chapter
Temporary marriage and the explanation that it was permitted then abrogated, then permitted then abrogated, and its prohibition was established until the Day of Resurrection
Numbering
Darussalam 3410
Muslim 3410