Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:3:36

But when she delivered her, she said, "My Lord, I have delivered a female." And Allah was most knowing of what she delivered, "And the male is not like the female. And I have named her Mary, and I seek refuge for her in You and ˹for˺ her descendants from Satan, the expelled ˹from the mercy of Allah˺."  

And when she gave birth to her, a girl, and she had been hoping for a boy, since only males were consecrated to the service of God, she said, apologetically, ‘O, Lord, I have given birth to a female’ — and God knew very well what she had given birth to: a parenthetical statement constituting God’s speech (a variant reading ˹for wada‘at, ‘she gave birth’, has wada‘tu, ‘I gave birth’ ˹making these Hanna’s words, sc. ‘and God knows very well what I have given birth to’˺); the male, that she had asked for, is not as the female, that was bestowed upon her, because he is designed for the service ˹of God˺, while she would not be suitable on account of her lesser physical ability, her private parts, the effects of menstruation on her, and so on. ‘And I have named her Mary, and commend her to You with her seed, her children, to protect them from the accursed, the outcast, Satan’. In a hadīth ˹it is stated˺: ‘Every new-born is touched by Satan and begins ˹life˺ by crying, except for Mary and her son’, as reported by the two Shaykhs ˹Bukhārī and Muslim˺.
القرآن:٣:٣٦

فَلَمَّا وَضَعَتْهَا قَالَتْ رَبِّ إِنِّي وَضَعْتُهَا أُنْثَىٰ وَاللَّهُ أَعْلَمُ بِمَا وَضَعَتْ وَلَيْسَ الذَّكَرُ كَالْأُنْثَىٰ ۖ وَإِنِّي سَمَّيْتُهَا مَرْيَمَ وَإِنِّي أُعِيذُهَا بِكَ وَذُرِّيَّتَهَا مِنَ الشَّيْطَانِ الرَّجِيمِ  

(فلما وضعتها) ولدتها جارية وكانت ترجو أن يكون غلامًا إذ لم يكن يحرر إلا الغلمان (قالت) معتذرة يا (رب إني وضعتها أنثى والله أعلم) أي عالم (بما وضعت) جملة اعتراض من كلامه تعالى وفي قراءة بضم التاء (وليس الذكر) الذي طلبت (كالأنثى) التي وهبت لأنه يقصد للخدمة وهي لا تصلح لضعفها وعورتها وما يعتريها من الحيض ونحوه (وإني سميتها مريم وإني أعيذها بك وذريتها) أولادها (من الشيطان الرجيم) المطرود في الحديث "" ما من مولود يولد إلا مسه الشيطان حين يولد فيستهل صارخًا إلا مريم وابنها "" رواه الشيخان.