Abstract This study investigated the molecular mechanisms underlying the regulation of MUC2 expression and O-glycosylation modification in colorectal cancer. In addition, the potential of rosiglitazone to inhibit colorectal cancer by improving MUC2 glycosylation to protect intestinal barrier function was explored. In vitro, lectin staining combined with Co-IP assay was used to detect glycosyltransferases regulating MUC2 O-glycosylation. ChIP and Luciferase experiments were used to verify the transcription factors regulating MUC2 expression level. Samples from CRC patients were used to detect differences in multimolecular expression. The AOM/DSS mouse model was used to validate the effect of rosiglitazone on inhibiting colorectal cancer progression. Our results showed that B3GNT6 acts as a glycosyltransferase to enhance the O-glycosylation level of MUC2 and maintain protein stability to resist degradation by StcE secreting from pathogenic bacteria. Furthermore, KLF4 directly promotes the transcription of B3GNT6 and MUC2, which are regulated by PPARg. Rosiglitazone activated PPARg-KLF4-B3GNT6 axis which increased the expression level and glycosylation of MUC2 and further improved the intestinal mucosal barrier function to delay the development of colorectal cancer in mice. These data suggest that O-glycosylation and expression of MUC2 is key to the maintenance of functional intestinal mucosa and rosiglitazone is a potential colorectal cancer therapeutic agent.