Answered by Shaykh Faraz Rabbani
Question: Can you please tell us the ruling on ultrasound or finding out the sex of the baby beforehand? Is there any prohibition for having an ultrasound done?
Answer: In the name of Allah, Most Merciful,
Walaikum assalam wa rahmatullah,
1. It is in itself permitted to find out the gender of the baby; there is nothing, in itself, to deem it prohibited or disliked.
2. If, however, it is linked with ignorant ideas of gender preference, it would be disliked, and impermissible (haram) when this would lead to unlawful abortion.
And Allah alone gives success.