The levels of glycemic control associated with the lowest risk of dementia in people with type 2 diabetes are unknown. This knowledge is critical to inform patient-centered glycemic target setting. To examine the associations between cumulative exposure to various ranges of glycated hemoglobin (HbA1c) concentrations with dementia risk across sex and racial and ethnic groups and the association of current therapeutic glycemic targets with dementia risk. This cohort study included members of the Kaiser Permanente Northern California integrated health care system with type 2 diabetes who were aged 50 years or older during the study period from January 1, 1996, to September 30, 2015. Individuals with fewer than 2 HbA1c measurements during the study period, prevalent dementia at baseline, or less than 3 years of follow-up were excluded. Data were analyzed from February 2020 to January 2023. Time-updated cumulative exposure to HbA1c thresholds. At each HbA1c measurement, participants were categorized based on the percentage of their HbA1c measurements that fell into the following categories: less than 6%, 6% to less than 7%, 7% to less than 8%, 8% to less than 9%, 9% to less than 10%, and 10% or more of total hemoglobin (to convert percentage of total hemoglobin to proportion of total hemoglobin, multiply by 0.01). Dementia diagnosis was identified using International Classification of Diseases, Ninth Revision codes from inpatient and outpatient encounters. Cox proportional hazards regression models estimated the association of time-varying cumulative glycemic exposure with dementia, adjusting for age, race and ethnicity, baseline health conditions, and number of HbA1c measurements. A total of 253 211 participants were included. The mean (SD) age of participants was 61.5 (9.4) years, and 53.1% were men. The mean (SD) duration of follow-up was 5.9 (4.5) years. Participants with more than 50% of HbA1c measurements at 9% to less than 10% or 10% or more had greater risk of dementia compared with those who had 50% or less of measurements in those categories (HbA1c 9% to <10%: adjusted hazard ratio [aHR], 1.31 [95% CI, 1.15-1.51]; HbA1c≥10%: aHR, 1.74 [95% CI, 1.62-1.86]). By contrast, participants with more than 50% of HbA1c concentrations less than 6%, 6% to less than 7%, or 7% to less than 8% had lower risk of dementia (HbA1c<6%: aHR, 0.92 [95% CI, 0.88-0.97]; HbA1c 6% to <7%: aHR, 0.79 [95% CI, 0.77-0.81]; HbA1c 7% to <8%: aHR, 0.93 [95% CI, 0.89-0.97]). In this study dementia risk was greatest among adults with cumulative HbA1c concentrations of 9% or more. These results support currently recommended relaxed glycemic targets for older people with type 2 diabetes.