Animals display a repertoire of different social behaviours. Appropriate behavioural responses depend on sensory input received during social interactions. In mice, social behaviour is driven by pheromones, chemical signals that encode information related to age, sex and physiological state1. However, although mice show different social behaviours towards adults, juveniles and neonates, sensory cues that enable specific recognition of juvenile mice are unknown. Here we describe a juvenile pheromone produced by young mice before puberty, termed exocrine-gland secreting peptide 22 (ESP22). ESP22 is secreted from the lacrimal gland and released into tears of 2- to 3-week-old mice. Upon detection, ESP22 activates high-affinity sensory neurons in the vomeronasal organ, and downstream limbic neurons in the medial amygdala. Recombinant ESP22, painted on mice, exerts a powerful inhibitory effect on adult male mating behaviour, which is abolished in knockout mice lacking TRPC2, a key signalling component of the vomeronasal organ2, 3. Furthermore, knockout of TRPC2 or loss of ESP22 production results in increased sexual behaviour of adult males towards juveniles, and sexual responses towards ESP22-deficient juveniles are suppressed by ESP22 painting. Thus, we describe a pheromone of sexually immature mice that controls an innate social behaviour, a response pathway through the accessory olfactory system and a new role for vomeronasal organ signalling in inhibiting sexual behaviour towards young. These findings provide a molecular framework for understanding how a sensory system can regulate behaviour.