Necrotizing enterocolitis (NEC) is the leading basis for gastrointestinal morbidity and poses a significant risk for neurodevelopmental impairment (NDI) in preterm infants. Aberrant bacterial colonization preceding NEC contributes to the pathogenesis of NEC, and we have demonstrated that immature microbiota in preterm infants negatively impacts neurodevelopment and neurological outcomes. In this study, we tested the hypothesis that microbial communities before the onset of NEC drive NDI. Using our humanized gnotobiotic model in which human infant microbial samples were gavaged to pregnant germ-free C57BL/6J dams, we compared the effects of the microbiota from preterm infants who went on to develop NEC (MNEC) to the microbiota from healthy term infants (MTERM) on brain development and neurological outcomes in offspring mice. Immunohistochemical studies demonstrated that MNEC mice had significantly decreased occludin and ZO-1 expression compared to MTERM mice and increased ileal inflammation marked by the increased nuclear phospho-p65 of NFκB expression, revealing that microbial communities from patients who developed NEC had a negative effect on ileal barrier development and homeostasis. In open field and elevated plus maze tests, MNEC mice had worse mobility and were more anxious than MTERM mice. In cued fear conditioning tests, MNEC mice had worse contextual memory than MTERM mice. MRI revealed that MNEC mice had decreased myelination in major white and grey matter structures and lower fractional anisotropy values in white matter areas, demonstrating delayed brain maturation and organization. MNEC also altered the metabolic profiles, especially carnitine, phosphocholine, and bile acid analogs in the brain. Our data demonstrated numerous significant differences in gut maturity, brain metabolic profiles, brain maturation and organization, and behaviors between MTERM and MNEC mice. Our study suggests that the microbiome before the onset of NEC has negative impacts on brain development and neurological outcomes and can be a prospective target to improve long-term developmental outcomes.