Serotonin (5-hydroxytryptamine) is a neurotransmitter crucial for cardiovascular, gastrointestinal, and brain function. It is also involved in several aspects of behavior and associated with a variety of personality disorders in humans. Its dual role as a crucial element in vital physiological functions (strictly evolutionary conserved) and in traits that differ substantially across species makes the evolution of serotonin function particularly interesting. We studied the evolution of serotonin function through the identification of the selective forces shaping the evolution of genes in its functional pathway in primates and rodents. Serotonin genes are highly conserved and show no signals of positive selection, suggesting functional constraint as the main force driving their evolution. They show, nevertheless, considerable differences in constraint between primates and rodents, with some genes showing dramatic differences between the 2 groups. These genes most likely represent cases of functional divergence between primates and rodents and point out to the relevance of using closely related species in gene-based evolutionary studies to avoid the effect of unrecognized functional differences between distant species. Within each group (rodents or primates), genes also show heterogeneity in evolution. Genes from the same gene family (with structure and function alike) tend to evolve at a similar rate, but this is not always the case. A few serotonin genes show substantial differences in constraint with the rest of members of their family, suggesting the presence of important and unrecognized functional differences among the genes, which may be involved in species-specific evolution.