Molecular fossils of 2-methylhopanoids are prominent biomarkers in modern and ancient sediments that have been used as proxies for cyanobacteria and their main metabolism, oxygenic photosynthesis. However, substantial culture and genomic-based evidence now indicates that organisms other than cyanobacteria can make 2-methylhopanoids. Because few data directly address which organisms produce 2-methylhopanoids in the environment, we used metagenomic and clone library methods to determine the environmental diversity of hpnP, the gene encoding the C-2 hopanoid methylase. Here we show that hpnP copies from alphaproteobacteria and as yet uncultured organisms are found in diverse modern environments, including some modern habitats representative of those preserved in the rock record. In contrast, cyanobacterial hpnP genes are rarer and tend to be localized to specific habitats. To move beyond understanding the taxonomic distribution of environmental 2-methylhopanoid producers, we asked whether hpnP presence might track with particular variables. We found hpnP to be significantly correlated with organisms, metabolisms and environments known to support plant-microbe interactions (P-value<10(-6)); in addition, we observed diverse hpnP types in closely packed microbial communities from other environments, including stromatolites, hot springs and hypersaline microbial mats. The common features of these niches indicate that 2-methylhopanoids are enriched in sessile microbial communities inhabiting environments low in oxygen and fixed nitrogen with high osmolarity. Our results support the earlier conclusion that 2-methylhopanoids are not reliable biomarkers for cyanobacteria or any other taxonomic group, and raise the new hypothesis that, instead, they are indicators of a specific environmental niche.