Number and arrangement of flagella, the bacterial locomotion organelles, are species-specific and serve as key taxonomic markers. The FlhG ATPase (also: YlxH, FleN), along with FlhF, plays pivotal roles in determining flagellation patterns. In Bacillus subtilis, FlhG and FlhF govern the spatial arrangement of peritrichous flagella. FlhG aids in flagellar assembly by interacting with the flagellar C-ring protein FliY, yet the molecular implications of this interaction have been unclear. Our study reveals that the ATP-dependent FlhG homodimer interacts with the C-terminal domain of GpsB, a cell cycle regulator, which recruits the peptidoglycan synthase PBP1 (also: ponA) to sites of cell wall elongation. A deletion of gpsB leads to dysregulation of the flagellation pattern mimicking the effects of a flhG deletion strain. The finding that GpsB can interact simultaneously with FlhG and PBP1, combined with the observation that GpsB and FliY can simultaneously interact with FlhG, strongly argues for a model in which FlhG confines flagella biosynthesis to regions of active cell wall biosynthesis. Thus, the FlhG-GpsB interaction appears to enable the locally restrained stimulation of the GTPase FlhF, known for its role to localize flagella in various bacterial species.