I study the effect of demographic change on economic growth under endogenous, R&D-driven technological change. Qualitatively, population ageing generates two opposing forces: increased R&D and capital investments on the one hand, and a decreasing share of workers in the population on the other. I evaluate these channels quantitatively along the demographic transition using a calibrated overlapping generations model with idiosyncratic income risk, mortality risk, intensive and extensive labour supply margins and endogenous technological change. Considering the United States between 1950 and 2100, I find that the demographic transition: (i) increased per-capita output by 0.35 percent per year between 1950 and 2000; (ii) accounts for a 0.65 percentage point decline in growth rates between 1995 and 2025 when the positive growth impact reverts back to trend; and (iii) has no net impact on twenty-first century growth. The main positive driver is endogenous technological change, whose growth contribution more than doubles that of capital deepening between 1950 and 2100. Removing this mechanism eliminates all positive growth effects.