We used to participate in the holy battles led by Messenger of Allah ﷺ and we had nothing (no wives) with us. So we said, "Shall we get ourselves castrated?" He forbade us that and then allowed us to marry women with a temporary contract (2) and recited to us: -- 'O you who believe ! Make not unlawful the good things which Allah has made lawful for you, but commit no transgression.' (5.87) (Using translation from Bukhārī 5075)
سَمِعْتُ عَبْدَ اللهِ يَقُولُ كُنَّا نَغْزُو مَعَ رَسُولِ اللهِ ﷺ لَيْسَ لَنَا نِسَاءٌ فَقُلْنَا أَلَا نَسْتَخْصِي فَنَهَانَا عَنْ ذَلِكَ رَسُولُ اللهِ ﷺ ثُمَّ رَخَّصَ لَنَا أَنْ نَنْكِحَ الْمَرْأَةَ بِالثَّوْبِ ثُمَّ قَرَأَ عَلَيْنَا {يَا أَيُّهَا الَّذِينَ آمَنُوا لَا تُحَرِّمُوا طَيِّبَاتِ مَا أَحَلَّ اللهُ لَكُمْ وَلَا تَعْتَدُوا إِنَّ اللهَ لَا يُحِبُّ الْمُعْتَدِينَ} [المائدة 87]