Adult male sexual behavior in mammals requires the neuronal organizing effects of gonadal steroids during a sensitive perinatal period. During development, estradiol differentiates the rat preoptic area (POA), an essential brain region in the male copulatory circuit. Here we report that increases in prostaglandin-E2 (PGE2), resulting from changes in cyclooxygenase-2 (COX-2) regulation induced by perinatal exposure to estradiol, are necessary and sufficient to organize the crucial neural substrate that mediates male sexual behavior. Briefly preventing prostaglandin synthesis in newborn males with the COX inhibitor indomethacin permanently downregulates markers of dendritic spines in the POA and severely impairs male sexual behavior. Developmental exposure to the COX inhibitor aspirin results in mild impairment of sexual behavior. Conversely, administration of PGE2 to newborn females masculinizes the POA and leads to male sex behavior in adults, thereby highlighting the pathway of steroid-independent brain masculinization. Our findings show that PGE2 functions as a downstream effector of estradiol to permanently masculinize the brain.