Groundwater harbors a pristine biosphere where microbes co-evolve with less human interference, yet the ancient and ongoing arms race between prokaryotes and viruses remains largely unknown in such ecosystems. Based on our recent nationwide groundwater monitoring campaign across China, we construct a metagenomic groundwater prokaryotic defensome catalogue (GPDC), encompassing 190,810 defense genes, 90,824 defense systems, 139 defense families, and 669 defense islands from 141 prokaryotic phyla. Over 94% of the defense genes in GPDC are novel and contribute vast microbial immune resources in groundwater. We find that candidate phyla radiation (CPR) bacteria possess higher defense system density and diversity against intense phage infection, while microbes as a whole exhibit an inverse relationship between defense systems and adaptive traits like resistance genes in groundwater. We further identify five first-line defense families covering 69.2% of the total defense systems, and high-turnover accessory immune genes are mostly conveyed to defense islands by mobile genetic elements. Our study also reveals viral resistance to microbial defense through co-localized anti-defense genes and interactions between CRISPR-Cas9 and anti-CRISPR protein. These findings expand our understanding of microbial immunity in pristine ecosystems and offer valuable immune resources for potential biotechnological applications.