The gender of a baby can typically be determined through ultrasound between 18 and 22 weeks of pregnancy, though some pregnancies may allow earlier detection. Sonographers look for the presence or absence of a penis and scrotum to identify male babies, or the three-line sign indicating female genitalia. Non-invasive prenatal testing (NIPT) blood tests can detect fetal sex as early as 9-10 weeks by analyzing fetal DNA in the mother's blood, though these are primarily used for chromosomal abnormality screening. At birth, sex is assigned based on external genital examination. It's important to note that biological sex (determined by anatomy and chromosomes) differs from gender identity, which develops over time. Ultrasound accuracy varies slightly—male identification is typically 95-99% accurate when clearly visible, while female identification is slightly less certain at around 95% accuracy, particularly in earlier scans. Some parents choose not to learn the baby's sex prenatally, preferring to wait for birth. The 18-22 week anatomy scan remains the most common and reliable method for most families seeking this information during pregnancy.