Enterohemorrhagic Escherichia coli (EHEC) O157:H7 has been known to cause outbreaks of hemorrhagic colitis and hemolytic uremic syndrome. We previously demonstrated that intestinal flora contribute to the prevention of EHEC infection in a mouse model. However, it has not yet been determined whether Bacteroides, a predominant genus in the human intestine, contributes to the prevention of EHEC infection. The aim of the present study was to investigate the effect of Bacteroides fragilis (B. fragilis) and Bacteroides vulgatus (B. vulgatus) on EHEC O157:H7 infection in vivo using gnotobiotic mice. These strains were inoculated into germ‑free mice to create a gnotobiotic mouse model. EHEC was inoculated into the mice, which were then monitored for 7 days for any change in symptoms. The mice that had been pre‑colonized with the Bacteroides strains did not develop lethal EHEC infection, although several inflammatory symptoms were observed in the B. vulgatus pre‑colonized group. However, no inflammatory symptoms were identified in the B. fragilis pre‑colonized group. Moreover, B. fragilis exerted an inhibitory effect on enterocyte‑like cell apoptosis. B. fragilis protected HT29 cells from apoptosis caused by Shiga toxin. In conclusion, the findings of the present study demonstrated that colonization by Bacteroides strains can inhibit EHEC infection.