The study followed 926,362 girls and women in Sweden born between 1985–2001, of whom 365,502 (39.5%) received at least one dose of the quadrivalent HPV vaccine. 930 cases of invasive cervical cancer were identified, of which 97 were vaccinated and 833 were unvaccinated. In women vaccinated before 17 years of age, the fully adjusted incidence ratio was 0.21 (95% CI 0.13–0.32) versus unvaccinated, with continued protection 13–15 years after vaccination (incidence ratio 0.23, 95% CI 0.16–0.46). For those vaccinated aged 17 years or older, the incidence ratio was 0.63 (95% CI 0.49–0.81), with a significant decrease 10–12 years after vaccination (incidence ratio 0.54, 95% CI 0.33–0.86). School cohorts had a 72% (95% CI 11–91%) lower risk of cervical cancer than the opportunistic cohort (incidence ratio 0.28, 95% CI 0.09–0.89), with no indication of waning protection. The study confirms long-term protection up to 18 years after vaccination at the population level.