Nitrogen fixation by gut microorganisms is one of the crucial aspects of symbiosis in wood-feeding termites since these termites thrive on a nitrogen-poor diet. In order to understand the evolution of this symbiosis, we analysed the nitrogenase structural gene nifH in the gut microbial communities. In conjunction with the published sequences, we compared approximately 320 putatively functional NifH protein sequences obtained from a total of 19 termite samples that represent all the major branches of their currently proposed phylogeny, and from one species of the cockroach Cryptocercus that shares a common ancestor with termites. Using multivariate techniques for clustering and ordination, a phylogeny of NifH protein sequences was created and plotted variously with host termite families, genera, and species. Close concordance was observed between NifH communities and the host termites at genus level, but family level relationships were not always congruent with accepted termite clade structure. Host groups examined included basal families (Mastotermitidae, Termopsidae, Kalotermitidae, as well as Cryptocercus), the most derived lower termite family Rhinotermitidae, and subfamilies representing the advanced and highly diverse apical family Termitidae (Macrotermitinae, Termitinae, and Nasutitermitinae). This selection encompassed the major nesting and feeding styles recognized in termites, and it was evident that NifH phylogenetic divergence, as well as the occurrence of alternative nitrogenase-type NifH, was to some extent dependent on host lifestyle as well as phylogenetic position.