Language:
كتاب التوحيد
97
Oneness, Uniqueness of Allah (Tawheed)
(18)
Chapter: “He is Allah, the Creator, the Inventor of all things, the Bestower of forms…”
(18)
Sahih al-Bukhari 7409

Narrated Abu Sa`id Al-Khudri:

That during the battle with Bani Al-Mustaliq they (Muslims) captured some females and intended to have sexual relation with them without impregnating them. So they asked the Prophet (ﷺ) about coitus interrupt us. The Prophet (ﷺ) said, "It is better that you should not do it, for Allah has written whom He is going to create till the Day of Resurrection." Qaza'a said, "I heard Abu Sa`id saying that the Prophet (ﷺ) said, 'No soul is ordained to be created but Allah will create it."

حَدَّثَنَا إِسْحَاقُ، حَدَّثَنَا عَفَّانُ، حَدَّثَنَا وُهَيْبٌ، حَدَّثَنَا مُوسَى ـ هُوَ ابْنُ عُقْبَةَ ـ حَدَّثَنِي مُحَمَّدُ بْنُ يَحْيَى بْنِ حَبَّانَ، عَنِ ابْنِ مُحَيْرِيزٍ، عَنْ أَبِي سَعِيدٍ الْخُدْرِيِّ، فِي غَزْوَةِ بَنِي الْمُصْطَلِقِ أَنَّهُمْ أَصَابُوا سَبَايَا فَأَرَادُوا أَنْ يَسْتَمْتِعُوا بِهِنَّ وَلاَ يَحْمِلْنَ فَسَأَلُوا النَّبِيَّ صلى الله عليه وسلم عَنِ الْعَزْلِ فَقَالَ ‏"‏ مَا عَلَيْكُمْ أَنْ لاَ تَفْعَلُوا، فَإِنَّ اللَّهَ قَدْ كَتَبَ مَنْ هُوَ خَالِقٌ إِلَى يَوْمِ الْقِيَامَةِ ‏"‏‏.‏ وَقَالَ مُجَاهِدٌ عَنْ قَزَعَةَ سَمِعْتُ أَبَا سَعِيدٍ فَقَالَ قَالَ النَّبِيُّ صلى الله عليه وسلم ‏"‏ لَيْسَتْ نَفْسٌ مَخْلُوقَةٌ إِلاَّ اللَّهُ خَالِقُهَا ‏"‏‏.‏
Reference : Sahih al-Bukhari 7409
In-book reference : Book 97, Hadith 38
USC-MSA web (English) reference : Vol. 9, Book 93, Hadith 506
  (deprecated numbering scheme)