Abdullah bin Masud reported,

We used to go on military campaigns with the Messenger of Allah ﷺ and we had nothing. We said, "Should we not castrate ourselves?" But he forbade us from doing that. Then he permitted us to marry a woman in exchange for a garment for a fixed term. Then he recited to us, "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].

Bukhari 5075

Sahih

حدثنا قتيبة بن سعيد حدثنا جرير عن إسماعيل عن قيس قال قال

عبد الله

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

البخاري 5075صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Marriage
Chapter
What is disliked of celibacy and castration
Numbering
Darussalam 5075
Bukhari 5075