Restriction-modification systems can protect bacteria against viral infection. Sequences of the hsdM gene, encoding one of the three subunits of type I restriction-modification systems, have been determined for four strains of enterobacteria. Comparison with the known sequences of EcoK and EcoR124 indicates that all are homologous, though they fall into three families (exemplified by EcoK, EcoA, and EcoR124), the first two of which are apparently allelic. The extent of amino acid sequence identity between EcoK and EcoA is so low that the genes encoding them might be better termed pseudoalleles; this almost certainly reflects genetic exchange among highly divergent species. Within the EcoK family the ratio of intra- to interspecific divergence is very high. The extent of divergence between the genes from Escherichia coli K-12 and Salmonella typhimurium LT2 is similar to that for other genes with the same level of codon usage bias. In contrast, intraspecific divergence (between E. coli strains B and K-12) is extremely high and may reflect the action of frequency-dependent selection mediated by bacteriophages. There is also evidence of lateral transfer of a short sequence between E. coli and S. typhimurium.