Sahih al-Bukhari, Hadith 5066 ⓘ
Narrated `Abdullah: We were with the Prophet while we were young and had no wealth whatever. So Allah's Messenger said, "O young people! Whoever among you can marry, should marry, because it helps him lower his gaze and guard his modesty (i.e. his private parts from committing illegal sexual intercourse etc.), and whoever is not able to marry, should fast, as fasting diminishes his sexual power."
حَدَّثَنَا عُمَرُ بْنُ حَفْصِ بْنِ غِيَاثٍ، حَدَّثَنَا أَبِي، حَدَّثَنَا الأَعْمَشُ، قَالَ حَدَّثَنِي عُمَارَةُ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ يَزِيدَ، قَالَ دَخَلْتُ مَعَ عَلْقَمَةَ وَالأَسْوَدِ عَلَى عَبْدِ اللَّهِ فَقَالَ عَبْدُ اللَّهِ كُنَّا مَعَ النَّبِيِّ صلى الله عليه وسلم شَبَابًا لاَ نَجِدُ شَيْئًا فَقَالَ لَنَا رَسُولُ اللَّهُ صلى الله عليه وسلم " يَا مَعْشَرَ الشَّبَابِ مَنِ اسْتَطَاعَ الْبَاءَةَ فَلْيَتَزَوَّجْ، فَإِنَّهُ أَغَضُّ لِلْبَصَرِ، وَأَحْصَنُ لِلْفَرْجِ، وَمَنْ لَمْ يَسْتَطِعْ فَعَلَيْهِ بِالصَّوْمِ، فَإِنَّهُ لَهُ وِجَاءٌ " .
also referenced under: Book 67, Hadith 4 (In-Book) & Volume 7, Book 62, Hadith 4 (USC-MSA)