No. The hadith says that after around forty nights an angel is commanded to write and carry out aspects of Allah's decree regarding the embryo. It does not say that chromosomal sex is biologically undetermined until then.
Do Not Conflate Two Authentic Hadiths
Two authentic narrations are often mixed together in this discussion.
The famous hadith of Ibn Masud mentions the stages in the womb and the writing of provision, lifespan, deeds, and final outcome. In its well-known wording, it does not mention "male or female":
The Messenger of Allah (PBUH), the truthful and truly inspired, said: "The creation of each one of you is brought together in his mother's womb for forty days, then he is a clinging clot for a similar period, then a lump of flesh for a similar period. Then the angel is sent to him, the soul is breathed into him, and he is commanded with four words: to write his provision, his lifespan, his deeds, and whether he will be wretched or blessed."
Sahih al-Bukhari 3208; Sahih Muslim 2643
The narration that explicitly mentions "male or female" is the hadith of Hudhayfah ibn Usayd (may Allah be pleased with him). In one authentic wording:
The Messenger of Allah (PBUH) said: "When forty-two nights have passed over the nutfah, Allah sends an angel to it. He shapes it and creates its hearing, sight, skin, flesh, and bones. Then he says: 'O Lord, male or female?' Then your Lord decrees whatever He wills, and the angel writes it..."
Sahih Muslim 2645
Other wordings from the same Companion mention forty or forty-five nights. In all cases, the report is speaking about angelic instruction, shaping, and writing at around this period.
The Hadith Is About Angelic Writing, Not Allah Learning Something New
The key words are that Allah sends an angel, the angel asks, Allah decrees what He wills, and the angel writes. The angel's question - "O Lord, male or female?" - is a request for what the angel is to write and carry out by Allah's command. It is not a claim that Allah only then learns or first decides the child's sex.
In Islamic belief, Allah's knowledge and will are eternal, and His decree is not formed for the first time at forty days. The Prophet (PBUH) said:
"Allah wrote the decrees of the creation fifty thousand years before He created the heavens and the earth."
Sahih Muslim
So the writing in the womb is a particular writing assigned to the angel. It is not the first moment at which the matter becomes known to Allah or enters Allah's decree.
The Quran Connects Male and Female to the Nutfah
The Quran itself connects the creation of male and female to the emitted nutfah:
"And that He creates the two mates, the male and the female, from a sperm-drop when it is emitted."
Quran 53:45-46
This verse is not giving a modern genetics lesson, but it is enough to refute the claim that Islamic revelation requires sex to be biologically unrelated to the earliest stage of reproduction. In ordinary human development, the chromosomal complement is established at fertilization when the sperm fertilizes the egg. The hadith does not deny that.
Biology and the Hadith Are Speaking About Different Things
Modern biology distinguishes between chromosomal sex, which is ordinarily set at fertilization, and the later development of reproductive anatomy. The gonads and genitalia pass through stages before their male or female features become clearly distinct.
The hadith speaks about the embryo being shaped after around forty-two nights and about the angel writing what Allah decrees. It does not say: "Chromosomes are assigned only at this time." Nor does "creates its hearing, sight, skin, flesh, and bones" mean that these organs are fully mature and functioning at that instant. It refers to their formation and development under Allah's command.
Conclusion
The objection fails because it reads into the hadith a biological claim that the hadith does not make. Islam teaches that Allah knows and decrees all things, that angels write and carry out what Allah commands, and that human development proceeds through physical causes created by Allah. The hadith about the angel after around forty-two nights concerns decree, writing, and embryonic formation - not a denial that chromosomal sex is established at conception.
For related discussions, see our articles on Quranic embryology and divine decree.