Abstract Background Viral-encoded auxiliary metabolic genes (AMGs) are important toolkits for modulating their hosts’ metabolisms and the microbial-driven biogeochemical cycles. Although the functions of AMGs have been extensively reported in numerous environments, we still know little about the drivers that shape the viral community-wide AMG compositions in natural ecosystems. Exploring the drivers of viral community-wide AMG compositions is critical for a deeper understanding of the complex interplays among viruses, hosts, and the environments. Results Here, we investigated the impact of viral lifestyles (i.e., lytic and lysogenic), habitats (i.e., water, particle, and sediment), and prokaryotic hosts on viral AMG profiles by utilizing metagenomic and metatranscriptomic techniques. We found that viral lifestyles were the most important drivers, followed by habitats and host identities. Specifically, irrespective of what habitats viruses came from, lytic viruses exhibited greater AMG diversity and tended to encode AMGs for chaperone biosynthesis, signaling proteins, and lipid metabolism, which could boost progeny reproduction, whereas temperate viruses were apt to encode AMGs for host survivability. Moreover, the lytic and temperate viral communities tended to mediate the microbial-driven biogeochemical cycles, especially nitrogen metabolism, in different manners via AMGs. When focusing on each lifestyle, we further found clear dissimilarity in AMG compositions between water and sediment, as well the divergent AMGs encoded by viruses infecting different host orders. Conclusions Overall, our study provides a first systematic characterization of the drivers of viral community-wide AMG compositions and further expands our knowledge of the distinct interactions of lytic and temperate viruses with their prokaryotic hosts from an AMG perspective, which is critical for understanding virus-host-environment interactions in natural conditions. Video Abstract