Animal behaviours that are superficially similar can express different intents in different contexts, but how this flexibility is achieved at the level of neural circuits is not understood. For example, males of many species can exhibit mounting behaviour towards same- or opposite-sex conspecifics, but it is unclear whether the intent and neural encoding of these behaviours are similar or different. Here we show that female- and male-directed mounting in male laboratory mice are distinguishable by the presence or absence of ultrasonic vocalizations (USVs), respectively. These and additional behavioural data suggest that most male-directed mounting is aggressive, although in rare cases it can be sexual. We investigated whether USV+ and USV− mounting use the same or distinct hypothalamic neural substrates. Micro-endoscopic imaging of neurons positive for oestrogen receptor 1 (ESR1) in either the medial preoptic area (MPOA) or the ventromedial hypothalamus, ventrolateral subdivision (VMHvl) revealed distinct patterns of neuronal activity during USV+ and USV− mounting, and the type of mounting could be decoded from population activity in either region. Intersectional optogenetic stimulation of MPOA neurons that express ESR1 and vesicular GABA transporter (VGAT) (MPOAESR1∩VGAT neurons) robustly promoted USV+ mounting, and converted male-directed attack to mounting with USVs. By contrast, stimulation of VMHvl neurons that express ESR1 (VMHvlESR1 neurons) promoted USV− mounting, and inhibited the USVs evoked by female urine. Terminal stimulation experiments suggest that these complementary inhibitory effects are mediated by reciprocal projections between the MPOA and VMHvl. Together, these data identify a hypothalamic subpopulation that is genetically enriched for neurons that causally induce a male reproductive behavioural state, and indicate that reproductive and aggressive states are represented by distinct population codes distributed between MPOAESR1 and VMHvlESR1 neurons, respectively. Thus, similar behaviours that express different internal states are encoded by distinct hypothalamic neuronal populations.