Interleukin-17 (IL-17) is a major pro-inflammatory cytokine: it mediates responses to pathogens or tissue damage, and drives autoimmune diseases. Little is known about its role in the nervous system. Here we show that IL-17 has neuromodulator-like properties in Caenorhabditis elegans. IL-17 can act directly on neurons to alter their response properties and contribution to behaviour. Using unbiased genetic screens, we delineate an IL-17 signalling pathway and show that it acts in the RMG hub interneurons. Disrupting IL-17 signalling reduces RMG responsiveness to input from oxygen sensors, and renders sustained escape from 21% oxygen transient and contingent on additional stimuli. Over-activating IL-17 receptors abnormally heightens responses to 21% oxygen in RMG neurons and whole animals. IL-17 deficiency can be bypassed by optogenetic stimulation of RMG. Inducing IL-17 expression in adults can rescue mutant defects within 6 h. These findings reveal a non-immunological role of IL-17 modulating circuit function and behaviour.