Innate social behaviours emerge from neuronal circuits that interpret sensory information on the basis of an individual's own genotype, sex and experience. The regulated aggregation behaviour of the nematode Caenorhabditis elegans, a simple animal with only 302 neurons, is an attractive system to analyse these circuits. Wild social strains of C. elegans aggregate in the presence of specific sensory cues, but solitary strains do not. Here we identify the RMG inter/motor neuron as the hub of a regulated circuit that controls aggregation and related behaviours. RMG is the central site of action of the neuropeptide receptor gene npr-1, which distinguishes solitary strains (high npr-1 activity) from wild social strains (low npr-1 activity); high RMG activity is essential for all aspects of social behaviour. Anatomical gap junctions connect RMG to several classes of sensory neurons known to promote aggregation, and to ASK sensory neurons, which are implicated in male attraction to hermaphrodite pheromones. We find that ASK neurons respond directly to pheromones, and that high RMG activity enhances ASK responses in social strains, causing hermaphrodite attraction to pheromones at concentrations that repel solitary hermaphrodites. The coordination of social behaviours by RMG suggests an anatomical hub-and-spoke model for sensory integration in aggregation, and points to functions for related circuit motifs in the C. elegans wiring diagram.