Ibn Abi Dhi'b (may Allah have mercy on him) says: I asked al-Zuhri (may Allah have mercy on him) about castration. He said: Ubaydullah bin Abdullah (may Allah have mercy on him) narrated to me that the Prophet (peace and blessings be upon him) forbade "confining a living creature (to kill it)." Al-Zuhri (may Allah have mercy on him) said: Castration is a severe kind of confinement.
Yunus and Ma'mar likewise narrated it from al-Zuhri as mursal. What is preserved (mahfuz) in this report is what al-Aqadi narrated from Ibn Abi Dhi'b, because Ma'mar and Yunus corroborate it. It has also been narrated on this from another route from Ibn Abbas (may Allah be pleased with him), with a chain that contains weakness.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب السبق والرمي / 19792