The importance of behavioral evolution during speciation is well established, but we know little about how this is manifest in sensory and neural systems. A handful of studies have linked specific neural changes to divergence in host or mate preferences associated with speciation. However, the degree to which brains are adapted to local environmental conditions, and whether this contributes to reproductive isolation between close relatives that have diverged in ecology, remains unknown. Here, we examine divergence in brain morphology and neural gene expression between closely related, but ecologically distinct, Heliconius butterflies. Despite ongoing gene flow, sympatric species pairs within the melpomene–cydno complex are consistently separated across a gradient of open to closed forest and decreasing light intensity. By generating quantitative neuroanatomical data for 107 butterflies, we show that Heliconius melpomene and Heliconius cydno clades have substantial shifts in brain morphology across their geographic range, with divergent structures clustered in the visual system. These neuroanatomical differences are mirrored by extensive divergence in neural gene expression. Differences in both neural morphology and gene expression are heritable, exceed expected rates of neutral divergence, and result in intermediate traits in first-generation hybrid offspring. Strong evidence of divergent selection implies local adaptation to distinct selective optima in each parental microhabitat, suggesting the intermediate traits of hybrids are poorly matched to either condition. Neural traits may therefore contribute to coincident barriers to gene flow, thereby helping to facilitate speciation.