Higher educational attainment is associated with reduced dementia risk, but the role of educational quality is understudied, presenting a major evidence gap, especially as it may contribute to racial inequities. To evaluate the association between state-level educational quality during childhood and dementia risk. This cohort study analyzed longitudinal data collected from January 1, 1997, through December 31, 2019 (23-year follow-up period). The sample comprised members of Kaiser Permanente Northern California (KPNC), a large integrated health care delivery system, who completed an optional survey during 1964-1972. Eligible individuals were US born; non-Hispanic Black or non-Hispanic White; aged 65 years or older as of January 1, 1996; were still alive; and did not have a dementia diagnosis or lapse in KPNC membership greater than 90 days between January 1 and December 31, 1996. Historical state-level administrative indicators of school quality (school term length, student-teacher ratio, and attendance rates) linked to participants using birth state and birth year (with a 6-year lag) and divided into tertiles using the pooled sample. Dementia diagnoses from electronic health records between 1997 and 2019 were analyzed between March 1 and August 31, 2022. The associations of educational quality with incident dementia were estimated using Cox proportional hazards regression models. Among 21 450 KPNC members who participated in the optional survey, individuals born before availability of educational quality records (n = 87) and missing educational attainment (n = 585) were excluded. The final analytic sample was 20 778 individuals (56.5% women, 43.5% men; mean [SD] age, 74.7 [6.5] years; 18.8% Black; 81.2% White; 41.0% with less than high school education). Among Black individuals, 76.2% to 86.1% (vs 20.8%-23.3% of White individuals) attended schools in states in the lowest educational quality tertiles. Highest (vs lowest) educational quality tertiles were associated with lower dementia risk (student-teacher ratio: hazard ratio [HR], 0.88 [95% CI, 0.83-0.94]; attendance rates: HR, 0.80 [95% CI, 0.73-0.88]; term length: HR, 0.79 [95% CI, 0.73-0.86]). Effect estimates did not differ by race and were not attenuated by adjustment for educational attainment. In this cohort study, lower state-average educational quality was more common among Black individuals and associated with higher dementia risk. Differential investment in high-quality education due to structural racism may contribute to dementia disparities.