Inflammation is associated with injury to immature lungs, and melatonin administration to preterm newborns with acute respiratory distress improves pulmonary outcomes. We hypothesized that maternally administered melatonin may reduce inflammation, oxidative stress, and structural injury in fetal lung and help fetal lung maturation in a mouse model of intrauterine inflammation (IUI). Mice were randomized to the following groups: control (C), melatonin (M), lipopolysaccharide (LPS; a model of IUI) (L), and LPS with melatonin (ML). Pro‐inflammatory cytokines, components of the Hippo pathway, and Yap1/Taz were analyzed in the fetal lung at E18 by real‐time RT‐qPCR. Confirmatory histochemistry and immunohistochemical analyses (surfactant protein B, vimentin, HIF‐1β, and CXCR2) were performed. The gene expression of IL1β in the fetal lung was significantly increased in L compared to C, M, and ML. Taz expression was significantly decreased in L compared to C and M. Taz gene expression in L was significantly decreased compared with those in ML. Immunohistochemical analyses showed that the expression of HIF‐1β and CXCR2 was significantly increased in L compared to C, M, and ML. The area of surfactant protein B and vimentin were significantly decreased in L than C, M, or ML in the fetal and neonatal lung. Antenatal maternally administered melatonin appears to prevent fetal lung injury induced by IUI and to help lung maturation. The results from this study results suggest that melatonin could serve as a novel safe preventive and/or therapeutic medicine for preventing fetal lung injury from IUI and for improving lung maturation in prematurity.