The bacterial flagellum is a complex molecular machine that is assembled by more than 30 proteins and is rotated to propel cells either through liquids or over solid surfaces. Flagellar gene expression is extensively regulated to co-ordinate flagellar assembly in both space and time. In Bacillus subtilis, the proteins of unknown function, SwrA and SwrB, and the alternative sigma factor σ D are required to activate expression of the flagellar filament protein, flagellin. Here we determine that in the absence of SwrA and SwrB, the phosphorylated form of the response regulator DegU inhibits σ d-dependent gene expression indirectly by binding to the P flgM promoter region and activating expression of the anti-sigma factor FlgM. We further demonstrate that DegU-P-dependent activation of FlgM is essential to inhibit flagellin expression when flagellar basal body assembly is disrupted. Regulation of FlgM is poorly understood outside of Salmonella, and differential control of FlgM expression may be a common means of coupling flagellin expression to flagellar assembly.