The human pathogen Helicobacter pylori displays extensive genetic diversity. While H. pylori is known to evolve during infection, population dynamics inside the gastric environment have not been extensively investigated. Here we obtained gastric biopsies from multiple stomach regions of 16 H. pylori-infected adults, and analyze the genomes of 10 H. pylori isolates from each biopsy. Phylogenetic analyses suggest location-specific evolution and bacterial migration between gastric regions. Migration is significantly more frequent between the corpus and the fundus than with the antrum, suggesting that physiological differences between antral and oxyntic mucosa contribute to spatial partitioning of H. pylori populations. Associations between H. pylori gene polymorphisms and stomach niches suggest that chemotaxis, regulatory functions and outer membrane proteins contribute to specific adaptation to the antral and oxyntic mucosa. Moreover, we show that antibiotics can induce severe population bottlenecks and likely play a role in shaping the population structure of H. pylori.