Is Finding the Baby’s Sex Before Birth Allowed in Islam?
Question

What is the ruling on finding the sex of the baby in the mother's womb before its birth by doing ultrasound and other medical equipment?
Praise be to Allah.Shaykh Muhammad ibn Salih Al-`Uthaymin (may Allah have mercy on him) said:
There is nothing wrong with finding out the sex of the baby before its birth unless it involves great expense. 
It could be said that it is a waste of money because there is no need to know the sex of the baby except for the purposes of merely feeling happy because one knows whether it is a boy or a girl. 
If finding out the sex of the baby in the mother's womb before its birth could not be achieved without spending a lot of money, then it is a waste of money and is not permitted. 
And Allah knows best.