The P2 porin protein is the most abundant outer membrane protein (OMP) of nontypeable Haemophilus influenzae (NTHI) and shows extensive antigenic heterogeneity among strains. To study the molecular basis of this heterogeneity, the DNA sequences of the genes encoding the P2 proteins of three unrelated strains of NTHI were determined, and restriction fragment length polymorphisms around the P2 genes of 35 strains were analyzed. The deduced amino acid sequences of the P2 genes from the three strains of NTHI revealed four major (12 to 35 amino acids long) and several smaller (2 to 7 amino acids) hypervariable regions in each protein. The major variations occurred in identical portions of the genes, and these regions showed a high antigenic index and surface exposure probability in computer modeling analysis. Differences in the molecular mass of the P2 protein correlate with differences in the size of the variable region in each strain. Oligonucleotide primers suitable for amplification of the P2 genes by polymerase chain reaction were developed. Restriction fragment length polymorphism analysis showed marked heterogeneity in and around the ompP2 locus of 35 NTHI strains. These results contrast with the high degree of conservation of the P2 genes in H. influenzae type b strains. We conclude that the molecular mass and antigenic heterogeneity of the P2 molecule of NTHI is due to variations in gene sequence that are clustered primarily in four large hypervariable regions of the gene.