A metagenomic analysis of two aquifer systems located under a dairy farming region was performed to examine to what extent the composition and function of microbial communities varies between confined and surface-influenced unconfined groundwater ecosystems. A fundamental shift in taxa was seen with an overrepresentation of Rhodospirillales, Rhodocyclales, Chlorobia and Circovirus in the unconfined aquifer, while Deltaproteobacteria and Clostridiales were overrepresented in the confined aquifer. A relative overrepresentation of metabolic processes including antibiotic resistance (β-lactamase genes), lactose and glucose utilization and DNA replication were observed in the unconfined aquifer, while flagella production, phosphate metabolism and starch uptake pathways were all overrepresented in the confined aquifer. These differences were likely driven by differences in the nutrient status and extent of exposure to contaminants of the two groundwater systems. However, when compared with freshwater, ocean, sediment and animal gut metagenomes, the unconfined and confined aquifers were taxonomically and metabolically more similar to each other than to any other environment. This suggests that intrinsic features of groundwater ecosystems, including low oxygen levels and a lack of sunlight, have provided specific niches for evolution to create unique microbial communities. Obtaining a broader understanding of the structure and function of microbial communities inhabiting different groundwater systems is particularly important given the increased need for managing groundwater reserves of potable water.