Courtship rituals serve to reinforce reproductive barriers between closely related species. Drosophila melanogaster and Drosophila simulans exhibit reproductive isolation, owing in part to the fact that D. melanogaster females produce 7,11-heptacosadiene, a pheromone that promotes courtship in D. melanogaster males but suppresses courtship in D. simulans males. Here we compare pheromone-processing pathways in D. melanogaster and D. simulans males to define how these sister species endow 7,11-heptacosadiene with the opposite behavioural valence to underlie species discrimination. We show that males of both species detect 7,11-heptacosadiene using homologous peripheral sensory neurons, but this signal is differentially propagated to P1 neurons, which control courtship behaviour. A change in the balance of excitation and inhibition onto courtship-promoting neurons transforms an excitatory pheromonal cue in D. melanogaster into an inhibitory cue in D. simulans. Our results reveal how species-specific pheromone responses can emerge from conservation of peripheral detection mechanisms and diversification of central circuitry, and demonstrate how flexible nodes in neural circuits can contribute to behavioural evolution.