Mishkat al-Masabih 3157
Ibn Mas'ud said :
When we were on an expedition along with God’s Messenger and had no women with us we asked whether we should not have ourselves castrated, but he forbade us to do that. Then he granted us licence to contract temporary marriages, and one would marry a woman giving a garment as dower up to a fixed date. Then ‘Abdallah recited, “You who believe, do not make unlawful the good things which God has made lawful for you” (Al-Qur’an 5:87).

(Bukhari and Muslim.)
عَنِ ابْنِ مَسْعُودٍ قَالَ: كُنَّا نَغْزُو مَعَ رَسُولِ اللَّهِ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ مَعَنَا نِسَاءٌ فَقُلْنَا: أَلَا نَخْتَصِي؟ فَنَهَانَا عَنْ ذَلِكَ ثُمَّ رَخَّصَ لَنَا أَنْ نَسْتَمْتِعَ فَكَانَ أَحَدُنَا يَنْكِحُ الْمَرْأَةَ بِالثَّوْبِ إِلَى أَجَلٍ ثُمَّ قَرَأَ عَبْدُ اللَّهِ: (يَا أَيُّهَا الَّذِينَ آمَنُوا لَا تُحَرِّمُوا طَيِّبَاتِ مَا أَحَلَّ اللَّهُ لَكُمْ)