Background: Diverse microbes catalyze biogeochemical cycles in the terrestrial subsurface, yet the corresponding ecophysiology was only estimated in a limited number of subterrestrial, often shallow aquifers. Here, we detrained the productivity, diversity, and functions of active microbial communities in the Judea Group carbonate and the underlying deep (up to 1.5 km below ground) Kurnub Group Nubian sandstone aquifers. These pristine oligotrophic aquifers, recharged more than tens to hundreds of thousands years ago, contain fresh/brackish, hypoxic/anoxic, often hot (up to 60°) water and serve as habitats for key microbial producers. Results: We show that recent groundwater recharge, inorganic carbon and ammonium strongly influence chemosynthetic primary productivity in carbonate and sandstone aquifers (4.4-21.9 μg C d-1 L-1 and 1.2-2.7 μg C d-1 L-1, respectively). These high values indicate the possibility that the global aquifer productivity rates may be underestimated. Metagenome analysis revealed the prevalence of chemoautotrophic pathways, particularly the Calvin-Benson-Bassham cycle. The key chemosynthetic lineages in the carbonate aquifer were Halothiobacillales, whereas Burkholderiales and Rhizobiales occupied the sandstone aquifer. Most chemosynthetic microbes may oxidize sulfur compounds or ammonium, using oxygen or oxidized nitrogen as electron acceptors. Abundant sulfate reducers in the anoxic deeper aquifer have the potential to catabolize various organics, fix carbon via the Wood Ljungdahl pathway, and often possess nitrogenase, indicating diazotrophic capabilities. Our data suggest that connectivity between the aquifers and their exposure to energy inputs and surface water may play a key role in shaping these communities, altering physicochemical parameters and selecting taxa and functions. We highlight the metabolic versatility in the deep subsurface that underpins their efficient harnessing of carbon and energy from different sources.