Thirst motivates animals to drink in order to maintain fluid balance. Thirst has conventionally been viewed as a homeostatic response to changes in blood volume or tonicity1,2,3. However, most drinking behaviour is regulated too rapidly to be controlled by blood composition directly, and instead seems to anticipate homeostatic imbalances before they arise4,5,6,7,8,9,10,11. How this is achieved remains unknown. Here we reveal an unexpected role for the subfornical organ (SFO) in the anticipatory regulation of thirst in mice. By monitoring deep-brain calcium dynamics, we show that thirst-promoting SFO neurons respond to inputs from the oral cavity during eating and drinking and then integrate these inputs with information about the composition of the blood. This integration allows SFO neurons to predict how ongoing food and water consumption will alter fluid balance in the future and then to adjust behaviour pre-emptively. Complementary optogenetic manipulations show that this anticipatory modulation is necessary for drinking in several contexts. These findings provide a neural mechanism to explain longstanding behavioural observations, including the prevalence of drinking during meals10,11, the rapid satiation of thirst7,8,9, and the fact that oral cooling is thirst-quenching12,13,14.