The pathogenesis of Crohn's disease (CD) is multifactorial and involves genetic susceptibility, environmental triggers and intestinal microbiota. Adherent-invasive Escherichia coli (AIEC) are flagellated bacteria more prevalent in CD patients than in healthy subjects and promote chronic intestinal inflammation. We aim at deciphering the role of flagella and flagellin modulation by intestinal conditions. AIEC flagellum expression is required for optimal adhesion to and invasion of intestinal epithelial cells. Interestingly, differential flagellin regulation was observed between commensal E. coli (HS) and AIEC (LF82) strains: flagellum expression by AIEC bacteria, in contrast to that of commensal E. coli, is enhanced under intestinal conditions (the presence of bile acids and mucins). Flagella are involved in the ability of the AIEC LF82 strain to cross a mucus layer in vitro and in vivo, conferring a selective advantage in penetrating the mucus layer and reaching the epithelial surface. In a CEABAC10 mouse model, a non-motile mutant (LF82-ΔfliC) exhibits reduced colonization that is restored by a dextran sodium sulfate treatment that alters mucus layer integrity. Moreover, a mutant that continuously secretes flagellin (LF82-ΔflgM) triggers a stronger inflammatory response than the wild-type strain, and the mutant's ability to colonize the CEABAC10 mouse model is decreased. Overexpression of flagellin in bacteria in contact with epithelial cells can be detrimental to their virulence by inducing acute inflammation that enhances AIEC clearance. AIEC pathobionts must finely modulate flagellum expression during the infection process, taking advantage of their specific virulence gene regulation to improve their adaptability and flexibility within the gut environment.