Adaptations to new pollinators involve multiple floral traits, each requiring coordinated changes in multiple genes. Despite this genetic complexity, shifts in pollination syndromes have happened frequently during angiosperm evolution. Here we study the genetic basis of floral UV absorbance, a key trait for attracting nocturnal pollinators. In Petunia, mutations in a single gene, MYB-FL, explain two transitions in UV absorbance. A gain of UV absorbance in the transition from bee to moth pollination was determined by a cis-regulatory mutation, whereas a frameshift mutation caused subsequent loss of UV absorbance during the transition from moth to hummingbird pollination. The functional differences in MYB-FL provide insight into the process of speciation and clarify phylogenetic relationships between nascent species.