BackgroundThe factors that maintain phenotypic and genetic variation within a population have received long-term attention in evolutionary biology. Here the genetic basis and evolution of the geographically widespread variation in twig trichome color (from red to white) in a shrubMelastoma normalewas investigated using Pool-seq and evolutionary analyses.ResultsThe results show that the twig trichome coloration is under selection in different light environments and that a 6-kb region containing an R2R3 MYB transcription factor gene is the major region of divergence between the extreme red and white morphs. This gene has two highly divergent groups of alleles, one of which likely originated from introgression from another species in this genus and has risen to high frequency (> 0.6) within each of the three populations under investigation. In contrast, polymorphisms in other regions of the genome show no sign of differentiation between the two morphs, suggesting that genomic patterns of diversity have been shaped by homogenizing gene flow. Population genetics analysis reveals signals of balancing selection acting on this gene, and it is suggested that spatially varying selection is the most likely mechanism of balancing selection in this case.ConclusionsThis study demonstrate that polymorphisms on a single transcription factor gene largely confer the twig trichome color variation inM. normale, while also explaining how adaptive divergence can occur and be maintained in the face of gene flow.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12915-023-01611-4.