To answer this we should look at the verses that relate to this matter. Allah says:
And He says:
If one reads the Arabic text of this verse, they will find that there is no Arabic word that corresponds to the English word ‘sex’ or ‘gender’. The Qur’an mentions only the knowledge of “what” is in the womb. Many have misunderstood this to mean the sex of the child in the womb, which is incorrect. Today, science has indeed advanced, and we can easily determine the sex of the child in the womb of a pregnant mother using ultrasound scanning. Therefore, the above verse refers to every aspect of the fetus’ present and future existence. What will be the child’s nature? Will the child be a blessing or a curse to the parents? What will happen to him or her throughout life? Will he or she do good or evil? How long will he or she live? Will he or she end up in Paradise or in Hell? Allah alone knows all of this… no scientist in the world, no matter how advanced the technology, will ever be able to determine these things about a child in the mother’s womb.