We used to go on military campaigns with the Messenger of Allah ﷺ without our wives being with us, so we said, "Messenger of Allah, shall we not castrate ourselves?" He forbade us from doing so, then later permitted us 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].
حدثنا محمد بن عبيد حدثنا إسماعيل عن قيس
كنا نغزو مع رسول الله ﷺ وليس لنا نساء فقلنا يا رسول الله ألا نستخصي فنهانا عنه ثم رخص لنا بعد في أن نتزوج المرأة بالثوب إلى أجل ثم قرأ عبد الله {يا أيها الذين آمنوا لا تحرموا طيبات ما أحل الله لكم ولا تعتدوا إن الله لا يحب المعتدين}
Its isnad is sahih. The two Shaykhs (Bukhari and Muslim) also narrated it, as noted in al-Muntaqa 3487 and the tafsir of Ibn Kathir 3:214. Ibn Masud held to this view and considered mutah marriage to be lawful. See the discussion of its abrogation in the commentary on al-Muntaqa. The beginning of the hadith has already been given at 2360, 3706.