Gut microbiota acts as a barrier against intestinal pathogens, but species-specific protection of the host from infection remains relatively unexplored. Although lactobacilli and bifidobacteria produce beneficial lactic and short-chain fatty acids in the mammalian gut, the significance of intestinal Escherichia coli producing these acids is debatable. Taking a Koch's postulates approach in reverse, we define Escherichia coli as health-promoting for naturally colonizing the gut of healthy mice and protecting them against intestinal colonization and concomitant mortality by Pseudomonas aeruginosa. Reintroduction of faecal bacteria and E. coli in antibiotic-treated mice establishes a high titre of E. coli in the host intestine and increases defence against P. aeruginosa colonization and mortality. Strikingly, high sugar concentration favours E. coli fermentation to lactic and acetic acid and inhibits P. aeruginosa growth and virulence in aerobic cultures and in a model of aerobic metabolism in flies, while dietary vegetable fats - not carbohydrates or proteins - favour E. coli fermentation and protect the host in the anaerobic mouse gut. Thus E. coli metabolic output is an important indicator of resistance to infection. Our work may also suggest that the lack of antimicrobial bacterial metabolites in mammalian lungs and wounds allows P. aeruginosa to be a formidable microbe at these sites.