We have examined the evolution of the genes at the major human beta-defensin locus and the orthologous loci in a range of other primates and mammals. For the first time, these data allow us to examine selective episodes in the more recent evolutionary history of this locus as well as in the ancient past. We have used a combination of maximum-likelihood-based tests and a maximum-parsimony-based sliding window approach to give a detailed view of the varying modes of selection operating at this locus. We provide evidence for strong positive selection soon after the duplication of these genes within an ancestral mammalian genome. During the divergence of primates, however, variable selective pressures have acted on beta-defensin genes in different evolutionary lineages, with episodes of both negative and, more rarely, positive selection. Positive selection appears to have been more common in the rodent lineage, accompanying the birth of novel rodent-specific beta-defensin gene clades. Sites in the second exon have been subject to positive selection and, by implication, are important in functional diversity. A small number of sites in the mature human peptides were found to have undergone repeated episodes of selection in different primate lineages. Particular sites were consistently implicated by multiple methods at positions throughout the mature peptides. These sites are clustered at positions that are predicted to be important for the function of beta-defensins.