Animals must integrate sensory cues with their current behavioral context to generate a suitable response, but how this integration occurs is poorly understood. Here we report that Caenorhabditis elegans uses inhibitory signals from turning-associated neurons to rapidly modulate mechanosensory processing depending on the animal's behavioral context. Using high-throughput optogenetic perturbations triggered on behavior, we show that turning associated neurons SAA, RIV and/or SMB suppress mechanosensory-evoked reversals during turns. We find that activation of the gentle-touch mechanosensory neurons or of any of the interneurons AIZ, RIM, AIB and AVE during a turn is less likely to evoke a reversal than activation during forward movement. Adding inhibition of SAA, RIV and SMB during a turn restores the likelihood with which mechanosensory activation evokes reversals. Seperately, activation of premotor interneuron AVA evokes reversals regardless of whether the animal is turning or moving forward. We therefore propose that inhibitory signals from SAA, RIV and/or SMB gate mechanosensory signals upstream of neuron AVA, and identify putative synapses and receptors where this gating occurs. We conclude that C. elegans relies on inhibitory feedback from the motor circuit to modulate its response to sensory stimuli on fast timescales. This need for motor signals in sensory processing may explain the ubiquity of motor-related neural activity patterns across the brain, including in sensory processing areas.