The causes underlying sex differences in lifespan are strongly debated. While females commonly outlive males in humans, this is generally less pronounced in societies before the demographic transition to low mortality and fertility rates. Life-history theory suggests that reduced reproduction should benefit female lifespan when females pay higher costs of reproduction than males. Using unique longitudinal demographic records on 140,600 reproducing individuals from the Utah Population Database, we demonstrate a shift from male-biased to female-biased adult lifespans in individuals born before versus during the demographic transition. Only women paid a cost of reproduction in terms of shortened post-reproductive lifespan at high parities. Therefore, as fertility decreased over time, female lifespan increased, while male lifespan remained largely stable, supporting the theory that differential costs of reproduction in the two sexes result in the shifting patterns of sex differences in lifespan across human populations. Further, our results have important implications for demographic forecasts in human populations and advance our understanding of lifespan evolution.