Abstract Background Mate finding and recognition in animals evolves during niche adaptation and involves social signals and habitat cues. Drosophila melanogaster and related species are known to be attracted to fermenting fruit for feeding and egg-laying, which poses the question of whether species-specific fly odours contribute to long-range premating communication. Results We have discovered an olfactory channel in D. melanogaster with a dual affinity to sex and food odorants. Female flies release a pheromone, (Z)-4-undecenal (Z4-11Al), that elicits flight attraction in both sexes. Its biosynthetic precursor is the cuticular hydrocarbon (Z,Z)-7,11-heptacosadiene (7,11-HD), which is known to afford reproductive isolation between the sibling species D. melanogaster and D. simulans during courtship. Twin olfactory receptors, Or69aB and Or69aA, are tuned to Z4-11Al and food odorants, respectively. They are co-expressed in the same olfactory sensory neurons, and feed into a neural circuit mediating species-specific, long-range communication; however, the close relative D. simulans, which shares food resources with D. melanogaster, does not respond to Z4-11Al. Conclusion The Or69aA and Or69aB isoforms have adopted dual olfactory traits. The underlying gene yields a collaboration between natural and sexual selection, which has the potential to drive speciation.