Sayyiduna Abu Hurayrah (may Allah be pleased with him) says: I came to the Prophet (peace and blessings be upon him) and said: "O Messenger of Allah (peace and blessings be upon him)! I am a young man, I fear falling into sin, and I do not find (the means) to marry a woman. Will you permit me to castrate myself?" He (peace and blessings be upon him) remained silent for a while. Then I repeated the same thing, and he (peace and blessings be upon him) again remained silent. Then I said it (a third time), and he (peace and blessings be upon him) said: "O Abu Hurayrah! The pen has dried concerning what you will meet; what is to happen will happen, whether you castrate yourself or not." [Sahih. Bukhari 5076]
Hadith Referenceالسنن الكبرى للبيهقي / كتاب النكاح / 13465