Bacterial populations harbor vast genetic diversity that is continually shaped by abiotic and biotic selective pressures, as well as by neutral processes. Individuals coexisting in the same geographically defined population often have significantly different gene content, but whether this variation is largely adaptive or neutral remains poorly understood. Here we quantify heterogeneity in gene content for two model marine microbes, Prochlorococcus and Pelagibacter, within and between populations in the Atlantic and Pacific Oceans, to begin to understand the selective pressures that are shaping these "population genomes." We discovered a large fraction of genes that are rare in each population, reflecting continual gene transfer and loss. Despite this high variation within each population, only a few genes significantly differ in abundance between the two biogeochemically distinct environments; nearly all of these are related to phosphorus acquisition and are enriched in the Atlantic relative to the Pacific. Moreover, P-related genes from the two sites form phylogenetically distinct clusters, whereas housekeeping genes do not, consistent with a recent spread of adaptive P-related genes in the Atlantic populations. These findings implicate phosphorus availability as the dominant selective force driving divergence between these populations, and demonstrate the promise of this approach for revealing selective agents in more complex microbial systems.