Mucin 2 (MUC2) is the skeleton of colonic mucus that comprises the physical intestinal barrier. Different dietary polysaccharides may affect colonic mucus at different extents. The effect of pectin on MUC2 production is contradictory. To investigate whether and how pectin affected hosts’ colonic mucus, the amount of MUC2 in colon, the cecal, mucosal microbiota, and metabolites profiles were analyzed and compared with inulin. The results showed pectin stimulated the production of MUC2 at a similar level to inulin. Both interventions increased the abundance of cecal Lachnospira and Christensenellaceae_R‐7_group, and enhanced the production of specific metabolites including soyasapogenol B 24‐O‐b‐d‐glucoside, lucyoside Q, trans‐EKODE‐(E)‐Ib, and 1,26‐dicaffeoylhexacosanediol. Additionally, pectin increased the relative abundance (RA) of cecal Lactobacillus, and induced less RA of potentially harmful bacteria such as Helicobacter in mucosal microbiota than inulin. In conclusion, we first reported that pectin and inulin stimulated the mucus formation at a similar level. Two genera of cecal bacteria and four metabolites may play an important role in enhancing the production of MUC2. Moreover, the MUC2 production may be unrelated to several traditional health‐beneficial bacteria; pectin possibly performed as good as or better than the inulin in rats’ gut.