Animals’ sensory systems adjust their responsiveness to environmental stimuli that vary greatly in their intensity. Here we report the neural mechanism of experience-dependent sensory adjustment, especially gain control, in the ASH nociceptive neurons in Caenorhabditis elegans . Using calcium imaging under gradual changes in stimulus intensity, we find that the ASH neurons of naive animals respond to concentration increases in a repulsive odor 2-nonanone regardless of the magnitude of the concentration increase. However, after preexposure to the odor, the ASH neurons exhibit significantly weak responses to a small gradual increase in odor concentration while their responses to a large gradual increase remain strong. Thus, preexposure changes the slope of stimulus–response relationships ( i . e ., gain control). Behavioral analysis suggests that this gain control contributes to the preexposure-dependent enhancement of odor avoidance behavior. Mathematical analysis reveals that the ASH response consists of fast and slow components, and that the fast component is specifically suppressed by preexposure. In addition, genetic analysis suggests that G protein signaling is required for the fast component. Thus, our integrative study demonstrates how prior experience dynamically modulates stimulus–response relationships in sensory neurons, eventually leading to adaptive modulation of behavior.