Horizontal gene transfer and selection are major forces driving microbial evolution. However, interactions between them are rarely studied. Phylogenetic analyses of purple bacterial carotenoid biosynthesis genes suggest two lineages: one producing spheroidenone and the other producing spirilloxanthin. Of the latter lineage, Rubrivivax gelatinosus S1 and Hoeflea phototrophica DFL-43 also or instead produce spheroidenone. Evolution of the spheroidenone pathway from that producing spirilloxanthin theoretically requires changes in the substrate specificity of upstream pathway enzymes and acquisition of a terminal ketolase (CrtA). In R. gelatinosus and likely also in H. phototrophica, CrtA was acquired from the Bacteroidetes, in which it functions as a hydroxylase. Estimation of nonsynonymous and synonymous mutations using several pairwise methods indicated positive selection upon both genes, consistent with their functional changes from hydroxylases to ketolases. Relaxed negative selection upon all other carotenoid biosynthetic genes in these organisms was also apparent, likely facilitating changes in their substrate specificities. Furthermore, all genes responsible for terminal carotenoid biosynthetic pathway steps were under reduced negative selection compared to those known to govern biosynthetic pathway specificity. Horizontal transfer of crtA into R. gelatinosus and H. phototrophica has therefore likely been promoted by (i) the apparent selective advantage of spheroidenone production relative to spirilloxanthin production, (ii) reduced negative selection upon other carotenoid biosynthetic genes, facilitating changes in their substrate specificities, and (iii) preexisting low enzyme substrate specificities due to relaxed negative selection. These results highlight the importance and complexity of selection acting upon both a horizontally transferred gene and the biochemical network into which it is integrating.