Sexual differentiation
Sexual differentiation is the process of development of the differences between males and females from an undifferentiated zygote (fertilized egg). As male and female individuals develop from zygotes into fetuses, into infants, children, adolescents, and eventually into adults, sex and gender differences at many levels develop: genes, chromosomes, gonads, hormones, anatomy, psyche, and social behaviors.
Sex differences range from nearly absolute to simply statistical. Sex-dichotomous differences are developments which are wholly characteristic of one sex only. Examples of sex-dichotomous differences include aspects of the sex-specific genital organs such as ovaries, a uterus or a phallic urethra. In contrast, sex-dimorphic differences are matters of degree (e.g., size of phallus). Some of these (e.g., stature, behaviors) are mainly statistical, with much overlap between male and female populations.
Nevertheless, even the sex-dichotomous differences are not absolute in the human population, and there are individuals who are exceptions (e.g., males with a uterus, or females with an XY karyotype), or who exhibit biological and/or behavioral characteristics of both sexes.
Sex differences may be induced by specific genes, by hormones, by anatomy, or by social learning. Some of the differences are entirely physical (e.g., presence of a uterus) and some differences are just as obviously purely a matter of social learning and custom (e.g., relative hair length). Many differences, though, such as gender identity, appear to be influenced by both biological and social factors ("nature" and "nurture").
The early stages of human differentiation appear to be quite similar to the same biological processes in other mammals and the interaction of genes, hormones and body structures is fairly well understood. In the first weeks of life, a fetus has no anatomic  or hormonal sex, and only a karyotype distinguishes male from female. Specific genes induce gonadal differences, which produce hormonal differences, which cause anatomic differences, leading to psychological and behavioral differences, some of which are innate and some induced by the social environment.
The various ways that genes, hormones, and upbringing affect different human behaviors and mental traits are difficult to test experimentally and charged with political conflict.

# Chromosomal sex differences
Humans have forty-six chromosomes, including two sex chromosomes, XX in females and XY in males. It is obvious that the Y chromosome must carry at least one essential gene which determines testicular formation (originally termed TDF). A gene in the sex-determining region of the short arm of the Y, now referred to as SRY, has been found to direct production of a protein which binds to DNA, inducing differentiation of cells derived from the genital ridges into testes. In transgenic XX mice (and some human XX males), SRY alone is sufficient to induce male differentiation.
Investigation of other cases of human sex reversal (XX males, XY females) has led to discovery of other genes crucial to testicular differentiation on autosomes (e.g., WT-1, SOX9, SF-1), and the short arm of X (DSS).

# Gonadal differentiation
Early in fetal life, germ cells migrate from structures known as yolk sacs to the genital ridge. By week 6, undifferentiated gonads consist of germ cells, supporting cells, and steroidogenic cells.
In a male, SRY and other genes induce differentiation of supporting cells into Sertoli cells and (indirectly) steroidogenic cells into Leydig cells to form testes, which become microscopically identifiable and begin to produce hormones by week 8. Germ cells become spermatogonia.
Without SRY, ovaries form during months 2-6. Failure of ovarian development in 45,X girls (Turner syndrome) implies that two functional copies of several Xp and Xq genes are needed. Germ cells become ovarian follicles. Supporting and steroidogenic cells become theca cells and granulosa cells, respectively.

# Hormonal differentiation
In a male fetus, testes produce steroid and protein hormones essential for internal and external anatomic differentiation. Leydig cells begin to make testosterone by the end of month 2 of gestation. From then on, male fetuses have higher levels of androgens in their systemic blood than females. The difference is even greater in pelvic and genital tissues. Antimullerian hormone (AMH) is a protein hormone produced by Sertoli cells from the 8th week on. AMH suppresses development of mullerian ducts in males, preventing development of a uterus.
Fetal ovaries produce estradiol, which supports follicular maturation but plays little part in other aspects of prenatal sexual differentiation, as maternal estrogen floods fetuses of both sexes.

# Genital differentiation
A differentiation of the sex organ can be seen. However, this is only the external genital differentiation. There is also an internal genital differentiation.

## Internal genital differentiation
Gonads are histologically distinguishable by 6-8 weeks of gestation. A fetus of that age has both mesonephric (wolffian) and paramesonephric (mullerian) ducts. Subsequent development of one set and degeneration of the other depends on the presence or absence of two testicular hormones: testosterone and AMH.  Disruption of typical development may result in the development of both, or neither, duct system, which may produce morphologically intersexual individuals.
Local testosterone causes each wolffian duct to develop into epididymis, vas deferens, and seminal vesicles. Without male testosterone levels, wolffian ducts degenerate and disappear. Mullerian ducts develop into a uterus, fallopian tubes, and upper vagina unless AMH induces degeneration. The presence of a uterus is stronger evidence of absence of testes than the state of the external genitalia.

## External genital differentiation
For illustrations, see the External links section.
By 7 weeks, a fetus has a genital tubercle, urogenital groove and sinus, and labioscrotal folds. In females, without excess androgens, these become the clitoris, urethra and vagina, and labia.
Males become externally distinct between 8 and 12 weeks, as androgens enlarge the phallus and cause the urogenital groove and sinus to fuse in the midline, producing an unambiguous penis with a phallic urethra, and a thinned, rugated scrotum.
A sufficient amount of any androgen can cause external masculinization. The most potent is dihydrotestosterone (DHT), generated from testosterone in skin and genital tissue by the action of 5-reductase. A male fetus may be incompletely masculinized if this enzyme is deficient. In some diseases and circumstances, other androgens may be present in high enough concentrations to cause partial or (rarely) complete masculinization of the external genitalia of a genetically female fetus.
Further sex differentiation of the external genitalia occurs at puberty, when androgen levels again become disparate. Male levels of testosterone directly induce growth of the penis, and indirectly (via DHT) the prostate.

# Breast differentiation
Visible differentiation occurs at puberty, when estradiol and other hormones cause breasts to develop in girls. However, fetal or neonatal androgens may modulate later breast development by reducing the capacity of breast tissue to respond to later estrogen.

# Hair differentiation
The amount and distribution of body hair differs between the sexes. Males have more terminal hair, especially on the face, chest, abdomen and back, and females have more vellus hair, which is less visible. This may also be linked to neoteny in humans, as vellus hair is a juvenile characteristic.

# Other body differentiation
The differentiation of other parts of the body than the sex organ creates the secondary sex characteristics.
General habitus and shape of body and face, as well as sex hormone levels, are similar in prepubertal boys and girls. As puberty progresses and sex hormone levels rise, obvious differences appear.
In males, testosterone directly increases size and mass of muscles, vocal cords, and bones, enhancing strength, deepening the voice, and changing the shape of the face and skeleton. Converted into DHT in the skin, it accelerates growth of androgen-responsive facial and body hair. Taller stature is largely a result of later puberty and slower epiphyseal fusion.
In females, in addition to breast differentiation, estrogen also widens the pelvis and increases the amount of body fat in hips, thighs, buttocks, and breasts. Estrogen also induces growth of the uterus, proliferation of the endometrium, and menses.
The difference in adult masculine and feminine faces is largely a result of heavier jaw and jaw muscle development induced by testosterone in late adolescence. Masculine features on average are slightly thicker and coarser. Androgen-induced recession of the male hairline accentuates these differences by middle adult life.
Sexual dimorphism of skeletal structure develops during childhood, and becomes more pronounced at adolescence.  Sexual orientation has been demonstrated to correlate with skeletal characters that become dimorphic during early childhood (such as arm length to stature ratio) but not with characters that become dimorphic during puberty (such as shoulder width) (Martin & Nguyen, 2004).

# Brain differentiation
In most animals, differences of exposure of a fetal or infant brain to sex hormones produce significant and irreversible differences of brain structure and function which correlate with adult reproductive behavior.
This seems to be the case in humans as well; sex hormone levels in male and female fetuses and infants differ, and both androgen receptors and estrogen receptors have been identified in brains. Several sex-specific genes not dependent on sex steroids are expressed differently in male and female human brains. Structural sex differences begin to be recognizable by 2 years of age, and in adult men and women include size and shape of corpus callosum and certain hypothalamic nuclei, and the gonadotropin feedback response to estradiol.

# Defeminization and masculinization
Defeminization and masculinization are the processes that a fetus goes through to become a male in sexual differentiation. In this perspective, the female is the default path for a developing human being, was it not for intervening factors that alter the path to the male one.
Biologically, this perspective is supported by that there is neither corresponding female genes nor female hormones to the ones that are active in males only. Estrogen, for instance, is present in both male and female fetuses.