To compare risk of dementia after age 50 by HIV status among individuals in a primary care setting. Observational cohort study; participants were identified from 2013 to 2017 and followed through 2019. Participants were people with HIV (PWH) on antiretroviral therapy (ART) and demographically similar people without HIV (PWOH), all at least 50 years old and with no prior diagnosis of dementia. The study setting was Kaiser Permanente Northern California, an integrated healthcare delivery system in the United States. Incident dementia diagnoses and baseline data on sociodemographics, smoking, alcohol use, other substance use, and clinical factors were gathered from the electronic health record. Cumulative proportion of incident dementia by HIV status was assessed using Kaplan–Meier curves. Unadjusted and adjusted hazard ratios for incident dementia by HIV status were generated using Cox proportional hazards models with age as the time scale. The study included 5381 PWH and 119 022 PWOH (average age at baseline: 57 and 58 years, respectively). Incident dementia was diagnosed in 117 PWH and 2427 PWOH. By age 80, 25.8% of PWH and 13.8% of PWOH had been diagnosed with dementia, corresponding with an unadjusted hazard ratio of 1.98 (95% CI 1.64-2.39). After adjustment for sociodemographic, substance use, and clinical factors, including frequency of outpatient visits, the risk of dementia among PWH remained elevated (vs. PWOH, adjusted hazard ratio = 1.58, 95% CI 1.31-1.92). Compared with PWOH, PWH were at 58% higher risk for dementia despite HIV treatment with ART. Research is needed to investigate the potential benefits of targeted risk factor management or earlier cognitive screening in this population.