Metagenomic surveys have revealed that natural microbial communities are predominantly composed of sequence-discrete, species-like populations but the genetic and/or ecological mechanisms that maintain such populations remain speculative, limiting our understanding of population speciation and adaptation to environmental perturbations. To address this knowledge gap, we sequenced 112 Salinibacter ruber isolates and 12 companion metagenomes recovered from four adjacent saltern ponds in Mallorca, Spain that were experimentally manipulated to dramatically alter salinity and light intensity, the two major drivers of these ecosystems. Our analyses showed that the pangenome of the local Sal. ruber population is open and similar in size (~15,000 genes) to that of randomly sampled Escherichia coli genomes. While most of the accessory (non-core) genes showed low in situ coverage based on the metagenomes compared to the core genes, indicating that they were functionally unimportant and/or ephemeral, 3.49% of them became abundant when salinity (but not light intensity) conditions changed and encoded for functions related to osmoregulation. Nonetheless, the ecological advantage of these genes, while significant, was apparently not strong enough to purge diversity within the population. Collectively, our results revealed a possible mechanism for how this immense gene diversity is maintained, which has implications for the prokaryotic species concept.