Pollinator attraction via chemical mimicry of insect sex pheromones acts as automatic magic trait in Mediterranean Ophrys orchids, underlying both divergent adaptation and reproductive isolation between different species. Chemical mimicry is also the defining feature of ecological speciation and adaptive radiation of Ophrys. SAD2 and SAD5, two members of a small gene family of acyl-ACP desaturases are mainly responsible for controlling the hydrocarbon double-bond composition of the pseudo-pheromone produced by the orchids, and thereby pollinator attraction and reproductive isolation. This makes them both major magic genes and ecological speciation genes. Evolutionary and molecular functional analysis of the desaturase family, including functional testing of resurrected (engineered) ancestral proteins, revealed how sex pheromone mimicry could have evolved from housekeeping functions of the ancestral desaturases and how selection by pollinators may have shaped the evolution of the speciation genes SAD2 and SAD5.