Late-onset sepsis (LOS) is thought to result from systemic spread of commensal microbes from the intestines of premature infants. Clinical use of probiotics for LOS prophylaxis has varied owing to limited efficacy, reflecting an incomplete understanding of relationships between development of the intestinal microbiome, neonatal dysbiosis and LOS. Using a model of LOS, we found that components of the developing microbiome were both necessary and sufficient to prevent LOS. Maternal antibiotic exposure that eradicated or enriched transmission of Lactobacillus murinus exacerbated and prevented disease, respectively. Prophylactic administration of some, but not all Lactobacillus spp. was protective, as was administration of Escherichia coli. Intestinal oxygen level was a major driver of colonization dynamics, albeit via mechanisms distinct from those in adults. These results establish a link between neonatal dysbiosis and LOS, and provide a basis for rational selection of probiotics that modulate primary succession of the microbiome to prevent disease.