Gut microbiota are shaped by a combination of ecological and evolutionary forces. While the ecological dynamics have been extensively studied, much less is known about how species of gut bacteria evolve over time. Here, we introduce a model-based framework for quantifying evolutionary dynamics within and across hosts using a panel of metagenomic samples. We use this approach to study evolution in approximately 40 prevalent species in the human gut. Although the patterns of between-host diversity are consistent with quasi-sexual evolution and purifying selection on long timescales, we identify new genealogical signatures that challenge standard population genetic models of these processes. Within hosts, we find that genetic differences that accumulate over 6-month timescales are only rarely attributable to replacement by distantly related strains. Instead, the resident strains more commonly acquire a smaller number of putative evolutionary changes, in which nucleotide variants or gene gains or losses rapidly sweep to high frequency. By comparing these mutations with the typical between-host differences, we find evidence that some sweeps may be seeded by recombination, in addition to new mutations. However, comparisons of adult twins suggest that replacement eventually overwhelms evolution over multi-decade timescales, hinting at fundamental limits to the extent of local adaptation. Together, our results suggest that gut bacteria can evolve on human-relevant timescales, and they highlight the connections between these short-term evolutionary dynamics and longer-term evolution across hosts. The human gut harbors a diverse microbial community whose composition is shaped by a variety of ecological forces. Given the high rates of turnover, the residents of this community might also have the opportunity to evolve over time by acquiring heritable changes to their genomes. Yet, despite the potential importance of these effects, we currently know very little about the evolutionary dynamics that occur within species in this complex community. Here, we introduce a new approach for extracting evolutionary signals from a large panel of human gut metagenomes and for interpreting these signals using simple null models from population genetics. We use this approach to quantify the evolutionary dynamics of approximately 40 prevalent species of gut bacteria, both within individual hosts and across the larger population. We find that resident populations of gut bacteria can evolve within their hosts on short timescales, but after many years, the resident populations are typically replaced by distantly related strains. The patterns of variation across hosts indicate widespread recombination within species, but the quantitative signals suggest interesting departures from traditional population genetic models. Together, these results show that short-term evolution in the gut microbiome may be more complex and widespread than is often assumed.