To reveal the variation of microbial community functions during water filtration process in river sediments, which has been utilized widely in natural water treatment systems, this study investigates the influence of municipal wastewater discharge to streams on the phylotype and metabolic potential of the microbiome in upstream and particularly various depths of downstream river sediments. Cluster analyses based on both microbial phylogenetic and functional data collectively revealed that shallow upstream sediments grouped with those from deeper subsurface downstream regions. These sediment samples were distinct from those found in shallow downstream sediments. Functional genes associated with carbohydrate, xenobiotic, and certain amino acid metabolisms were overrepresented in upstream and deep downstream samples. In contrast, the more immediate contact with wastewater discharge in shallow downstream samples resulted in an increase in the relative abundance of genes associated with nitrogen, sulfur, purine and pyrimidine metabolisms, as well as restriction–modification systems. More diverse bacterial phyla were associated with upstream and deep downstream sediments, mainly including Actinobacteria, Planctomycetes, and Firmicutes. In contrast, in shallow downstream sediments, genera affiliated with Betaproteobacteria and Gammaproteobacteria were enriched with putative functions that included ammonia and sulfur oxidation, polyphosphate accumulation, and methylotrophic bacteria. Collectively, these results highlight the enhanced capabilities of microbial communities residing in deeper stream sediments for the transformation of water contaminants and thus provide a foundation for better design of natural water treatment systems to further improve the removal of contaminants.