If what the doctors said about this is confirmed, that this is because of a hereditary disease that affects females but not males, and it is not just speculation, then in this case there is nothing wrong with aborting the foetus if it is female, on condition that this happens before the soul is blown into it. The soul is blown into it after one hundred and twenty days from the beginning of the pregnancy. But if the soul has already been blown into it, then it is not permissible to abort it for this reason, because now it has become a human being whose life is sacred and it is not permissible to transgress against it.
This has been discussed in the answer to question number 12289.
With regard to choosing the gender of the foetus and opting for a male, there is nothing wrong with that in this case, if the words of the doctors are confirmed, as stated above. There is nothing wrong with medical intervention and choosing the gender of the foetus (male), hoping that he will be free from this disease.
The Islamic Fiqh Council has issued a statement concerning the subject of choosing the sex of the foetus, the text of which is as follows:
Praise be to Allah alone, and blessings and peace be upon the one after whom there is no Prophet, our Prophet Muhammad, and upon his family and Companions. To proceed:
The Islamic Fiqh Council belonging to the Muslim World League, in its nineteenth session held in Makkah al-Mukarramah, 22-27 Shawwaal 1428 AH/3-8 November 2007 CE, examined the issue of choosing the gender of the foetus. After listening to the research that was presented, consulting specialists and a great deal of discussion,
The Council affirms that the basic principle for the Muslim is to accept the will and the decree of Allah and to be content with whatever children Allah blesses him with, whether they are male or female, and he should praise Allah for that, as the choice of the Creator is best for us, may He be glorified and exalted, chooses.
In the Holy Qur’aan there is criticism of the people of the Jaahiliyyah for not accepting and being content with the child if it was female. Allah says (interpretation of the meaning):
“And when the news of (the birth of) a female (child) is brought to any of them, his face becomes dark, and he is filled with inward grief!
59. He hides himself from the people because of the evil of that whereof he has been informed. Shall he keep her with dishonour or bury her in the earth? Certainly, evil is their decision”
There is nothing wrong with a person wanting a child to be male or female, based on the fact that the Holy Qur'aan refers to the supplication of some of the Prophets asking that they be blessed with a male child.
In the light of that, the Council has determined the following:
It is permissible to choose the gender of the foetus by natural means, such as following a certain nutrition plan, chemical washes, and choosing times for intercourse according to the time of ovulation, because these are permissible means and there are no reservations about them.
It is not permissible to use any kind of medical intervention to choose the gender of the foetus, except in cases of medical necessity with regard to hereditary diseases which affect males but not females or vice versa. In that case intervention is permissible, subject to established shar‘i guidelines, so long as that is done on the basis of a committee of specialist doctors consisting of no less than three doctors of good character, who produce a medical report stating that the case calls for medical intervention so that the foetus will not be affected by the hereditary disease. Then after that, this medical report should be submitted to the Department for Issuing Fatwas so that they may issue a ruling as they see fit in that case.
It is essential to establish “watchdog” committees that will keep a close watch on hospitals and medical centres which carry out such procedures in Muslim countries, so as to prevent any practices that may go against the content of the report. In Muslim countries official bodies should set up systems and guidelines to achieve this.
May Allah send blessings and peace upon our Prophet Muhammad and his family and Companions. End quote.
[Link to the fatwa (in Arabic): http://www.themwl.org/Fatwa/default.aspx?d=1&cidi=168&l=AR&cid=12]
And Allah knows best.