HLA-B27 represents a family of 23 closely related alleles (B*2701-23) that differ at 24 amino acid positions. The pattern of polymorphisms of B27 was studied, with special reference to synonymous (Ks) and nonsynonymous (Ka) divergence among alleles. B27 alleles are characterized by the enhanced rate of nonsynonymous nucleotide substitution in the peptide-binding region (PBR). The percentage of substitutions between each of the B27 pairs ranges from 0.2%-3% in exons 2-3 to 1.8%-20.1% in the PBR. A phylogenetic analysis of all B27 alleles is described in order to identify subtypes with a common evolutionary history. These results, together with the phylogenetic trees obtained from the comparison between exons 2-3 and PBR indicate that polymorphism of B27 is selectively maintained. Most of the differences are clustered in the C/F pocket affecting the specific binding of antigenic peptides. Gene conversion and point mutation are the most important mechanisms responsible for B27 diversification. The interaction of selection, genetic drift, and recombination events is important for generating polymorphism at B27 alleles. We analyzed a large extended B27 positive population from different parts of the world. Our results indicate that B27 subtypes differ in their ethnic distribution, which may be the result of different genetic and geographical origins. Different factors such as genetic drift, bottleneck effect, and admixture among populations could contribute to the genetic constitution of B27. The striking correlation between the structural features of B27 and the ethnic distribution of these subtypes suggests a model of strong directional evolution, in which the subtypes could have arisen from B*2705.