The balanced gut microbiota in intestinal mucus layer plays an instrumental role in the health of the host. However, the mechanisms by which the host regulates microbial communities in the mucus layer remain largely unknown. Here, we discovered that the host regulates bacterial colonization in the gut mucus layer by producing a protein called Chitinase 3-like protein 1 (Chi3l1). Intestinal epithelial cells are stimulated by the gut microbiota to express Chi3l1. Once expressed, Chi3l1 is secreted into the mucus layer where it interacts with the gut microbiota, specifically through a component of bacterial cell walls called peptidoglycan. This interaction between Chi3l1 and bacteria is beneficial for the colonization of bacteria in the mucus, particularly for Gram-positive bacteria like Lactobacillus. Moreover, a deficiency of Chi3l1 leads to an imbalance in the gut microbiota, which exacerbates colitis induced by dextran sodium sulfate. By performing fecal microbiota transplantation from Villin-cre mice or replenishing Lactobacillus in IEC∆Chil1 mice, we were able to restore their colitis to the same level as that of Villin-cre mice. In summary, this study shows a ‘scaffold model’ for microbiota homeostasis by interaction between intestinal Chi3l1 and bacteria cell wall interaction, and it also highlights that an unbalanced gut microbiota in the intestinal mucus contributes to the development of colitis.