We used to go on military campaigns with the Prophet ﷺ without our wives accompanying us, so we asked, "Should we castrate ourselves?" He forbade us from doing that, but later permitted us to contract a temporary marriage with a woman in exchange for a garment. Then he recited, "You who believe, do not forbid the good things that Allah has made lawful for you" [Maidah 5:87].
حدثنا عمرو بن عون حدثنا خالد عن إسماعيل عن قيس
كنا نغزو مع النبي ﷺ وليس معنا نساء فقلنا ألا نختصي فنهانا عن ذلك فرخص لنا بعد ذلك أن نتزوج المرأة بالثوب ثم قرأ {يا أيها الذين آمنوا لا تحرموا طيبات ما أحل الله لكم}