In utero exposure to COVID-19 infection may lead to large intergenerational health effects. The impact of infection exposure has likely evolved since the onset of the pandemic as new variants emerge, immunity from prior infection increases, vaccines become available, and vaccine hesitancy persists, such that when infection is experienced is as important as whether it is experienced. We examine the changing impact of COVID-19 infection on preterm birth and the moderating role of vaccination. We offer the first plausibly causal estimate of the impact of maternal COVID-19 infection by using population data with no selectivity, universal information on maternal COVID-19 infection, and linked sibling data. We then assess change in this impact from 2020 to 2023 and evaluate the protective role of COVID-19 vaccination on infant health. We find a substantial adverse effect of prenatal COVID-19 infection on the probability of preterm birth. The impact was large during the first 2 y of the pandemic but had fully disappeared by 2022. The harmful impact of COVID-19 infection disappeared almost a year earlier in zip codes with high vaccination rates, suggesting that vaccines might have prevented thousands of preterm births. The findings highlight the need to monitor the changing consequences of emerging infectious diseases over time and the importance of mitigation strategies to reduce the burden of infection on vulnerable populations.