Pyloric stenosis occurs with a nearly 5-fold male predominance. To what extent this is due to environmental factors is unknown. In a cohort of all children born in Denmark, 1977-2008, the authors examined the association between pre- and perinatal exposures and pyloric stenosis and investigated whether these factors modified the male predominance. Information on pre- and perinatal factors and pyloric stenosis was obtained from national registers. Poisson regression models were used to estimate rate ratios. Among 1,925,313 children, 3,174 had surgery for pyloric stenosis. The authors found pyloric stenosis to be significantly associated with male sex, age between 2 and 7 weeks, early study period, being first born, maternal smoking during pregnancy, preterm delivery, small weight for gestational age, cesarean section, and congenital malformations. Among cases, 2,595 were males and 579 were females. Lower male predominance was associated with age at diagnosis outside the peak ages, early study period, no maternal smoking during pregnancy, preterm delivery, and congenital malformations. The authors have previously found a strong familial aggregation of pyloric stenosis indicating a genetic influence. This study shows that environmental factors during and shortly after pregnancy also play a role and that several of these modify the strong male predominance.