Reversible switching of the bacterial flagellar motor between clockwise (CW) and counterclockwise (CCW) rotation is necessary for chemotaxis, which enables cells to swim towards favorable chemical habitats. Increase in the viscous resistance to the rotation of the motor (mechanical load) inhibits switching. However, cells must maintain homeostasis in switching to navigate within environments of different viscosities. The mechanism by which the cell maintains optimal chemotactic function under varying loads is not understood. Here, we show that the flagellar motor allosterically controls the binding affinity of the chemotaxis response regulator, CheY-P, to the flagellar switch complex by modulating the mechanical forces acting on the rotor. Mechanosensitive CheY-P binding compensates for the load-induced loss of switching by precisely adapting the switch response to a mechanical stimulus. The interplay between mechanical forces and CheY-P binding tunes the chemotactic function to match the load. This adaptive response of the chemotaxis output to mechanical stimuli resembles the proprioceptive feedback in the neuromuscular systems of insects and vertebrates.