As regard the question, the following is the fatwa, issued by Sheikh `Atiyyah Saqr the former head of Al-Azhar Fatwa Committee, in this regard:
“Allah Almighty has created males and females and given each of them the ability, through sexual intercourse, to procreate in order to populate the earth. Sterilization means rendering either the male or the female unable to produce children and fulfill this function.
a long time ago, men used to undergo castration. Nowadays, they have a vasectomy (ligation of the spermatic cord) or take medication to stop sperm production.
Women also undergo surgery to prevent the uterus from performing its natural function, e.g. stopping the process of ova generation, fallopian tube ligation, hysterectomy, etc.
It is permissible for medical reasons to postpone pregnancy for some time. But it is forbidden to stop the natural process of fertilization of either man or woman, unless there is an urgent need to do so. Preventing the reproductive organs from performing their natural function contradicts the Divine Wisdom behind creating both sexes.
In addition, such acts can cause some changes in the natural qualifications of either sex, so that there can be alteration in one’s voice, feelings, etc., and this can be reflected in one’s behavior.
this is supported by the Prophet’s prohibition of castration. Al-Bukhari narrates, on the authority of Abu Hurayrah (may Allah be pleased with him) that he sought the Prophet’s permission to undergo castration, for he could not afford to get married. Thus, he wanted to protect himself from committing fornication.
also, in a hadith narrated by Imam Ahmad, the Prophet (peace and blessings be upon him) forbade fighters in the cause of Allah, who left their wives at home, from getting castrated.
the Prophet (peace and blessings of Allah be upon him) says to a man who sought his permission to be emasculated: “Instead of castration, you can observe fasting and prayer (as a kind of protection against unlawful actions).” (Reported by At-Tabarani and Ahmad) The same ruling goes with sterilization for women: it is forbidden.

Obstetricians and gynecologists declare that pregnancy keeps the balance of vital processes in women’s bodies. Thus, preventing it altogether is a form of challenging nature. According to the consensus of jurists, stopping the process of ova production is forbidden.
also, women who sterilize themselves for having enough children cannot determine the vicissitudes of time; they do not know the fate of these children. If there are methods of contraception, couples should not resort to sterilization, for they may regret it later.
Imam Ahmad permitted women to take some medication to prevent the menstruation but not to sterilize. He did not permit it absolutely except if there is a medical urgency that necessitates it, such as hereditary diseases. After all, necessity is judged by its urgency.”