Abdul Rahman bin Shamasah al-Mahri (may Allah have mercy on him) narrates from Sayyiduna Abdullah bin Amr (may Allah be pleased with them both) that the Messenger of Allah (peace and blessings be upon him) visited Umm Ibrahim, Mariyah the Copt (may Allah be pleased with her), his umm walad (slave mother of his child), while she was pregnant by him with Ibrahim. He (peace and blessings be upon him) found with her a relative of hers who had come with her from Egypt; he had accepted Islam and his Islam was good, and he used to visit Umm Ibrahim. He was so content with his position with the umm walad of the Messenger of Allah (peace and blessings be upon him) that he castrated himself; he cut off what was between his legs until he left nothing of it for himself, little or much. One day the Messenger of Allah (peace and blessings be upon him) went to Umm Ibrahim and found her relative with her, and there came into his heart about it the same thing that comes into the hearts of ordinary people, and he (peace and blessings be upon him) returned with his colour changed. He (peace and blessings be upon him) met Sayyiduna Umar (may Allah be pleased with him) and told him what had come into his heart concerning Umm Ibrahim's relative. Sayyiduna Umar (may Allah be pleased with him) took up his sword and went running to Mariyah, and there he found that same relative of hers with her. He moved to strike him with the sword to kill him. When that man saw this, he exposed his condition. When Sayyiduna Umar (may Allah be pleased with him) saw this, he went back to the Messenger of Allah (peace and blessings be upon him) and informed him. Thereupon the Prophet (peace and blessings be upon him) said: "Shall I not tell you that Jibril (peace be upon him) came to me and informed me that Allah, the Mighty and Majestic, has declared her and her relative innocent of what had come into my heart, and gave me the glad tidings that in her womb is a son of mine, and that he will be the most resembling of all creation to me, and commanded me to name him Ibrahim, and gave me the kunyah Abu Ibrahim. Were it not that I dislike changing the kunyah by which I am known, I would have taken the kunyah Abu Ibrahim, as Jibril (peace be upon him) gave it to me."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 13742