The expansion of Enterobacteriaceae, such as E. coli is a main characteristic of gut inflammation and is related to multiple human diseases. However, how to control these E. coli overgrowth is not well understood. Here, we demonstrate that gut complement factor D (CFD) plays an important role in eliminating E. coli. Increased E. coli, which could stimulate inflammatory macrophages to induce colitis, were found in the gut of CFD deficient mice. We also showed that gut Reg4, which is expressed in gut epithelial cells, stimulated complement-mediated attack complexes to eliminate E. coli. Reg4 deficient mice also had increased E. coli. The dominant E. coli were isolated from colitis tissues of mice and found to be sensitive to both CFD- and Reg4-mediated attack complexes. Thus, gut Reg4- and CFD-mediated membrane attack complexes may maintain gut homeostasis by killing inflammatory E. coli.