Mucosal-associated invariant T (MAIT) cells are predominantly located in barrier tissues where they rapidly respond to pathogens and commensals by recognizing microbial derivatives of riboflavin synthesis. Early-life exposure to these metabolites imprints the abundance of MAIT cells within tissues, so we hypothesized that antibiotic use during this period may abrogate their development. We identified antibiotics that deplete riboflavin-synthesizing commensals and revealed an early period of susceptibility during which antibiotic administration impaired MAIT cell development. The reduction in MAIT cell abundance rendered mice more susceptible to pneumonia, while MAIT cell-deficient mice were unaffected by early-life antibiotics. Concomitant administration of a riboflavin-synthesizing commensal during antibiotic treatment was sufficient to restore MAIT cell development and immunity. Our work demonstrates that transient depletion of riboflavin-synthesizing commensals in early life can adversely affect responses to subsequent infections.