Dissecting the genetic basis for the evolution of species differences requires a combination of phylogenetic and molecular genetic perspectives. By mapping the genetic changes and their phenotypic effects onto the phylogeny, it is possible to distinguish changes that may have been directly responsible for a new character state from those that fine tune the transition. Here, we use phylogenetic and functional methods to trace the evolution of substrate specificity in dihydroflavonol-4-reductase (Dfr), an anthocyanin pathway gene known to be involved in the transition from blue to red flowers in Iochroma. Ancestral state reconstruction indicates that three substitutions occurred during the flower color transition, whereas several additional substitutions followed the transition. Comparisons of enzymatic function between ancestral proteins in blue- and red-flowered lineages and proteins from present-day taxa demonstrate that evolution of specificity for red pigment precursors was caused by the first three substitutions, which were fixed by positive selection and which differ from previously documented mutations affecting specificity. Two inferred substitutions subsequent to the initial flower color transition were also adaptive and resulted in an additional increase in specificity for red precursors. Epistatic interactions among both sets of substitutions may have limited the order of substitutions along branches of the phylogeny leading from blue-pigmented ancestors to the present-day red-flowered taxa. These results suggest that the species differences in DFR specificity may arise by a combination of selection on flower color and selection for improved pathway efficiency but that the exact series of genetic changes resulting in the evolution of specificity is likely to be highly contingent on the starting state.