ImportanceEpilepsy has been associated with cognitive impairment and potentially dementia in older individuals. However, the extent to which epilepsy may increase dementia risk, how this compares with other neurological conditions, and how modifiable cardiovascular risk factors may affect this risk remain unclear.ObjectiveTo compare the differential risks of subsequent dementia for focal epilepsy compared with stroke and migraine as well as healthy controls, stratified by cardiovascular risk.Design, Setting, and ParticipantsThis cross-sectional study is based on data from the UK Biobank, a population-based cohort of more than 500 000 participants aged 38 to 72 years who underwent physiological measurements and cognitive testing and provided biological samples at 1 of 22 centers across the United Kingdom. Participants were eligible for this study if they were without dementia at baseline and had clinical data pertaining to a history of focal epilepsy, stroke, or migraine. The baseline assessment was performed from 2006 to 2010, and participants were followed up until 2021.ExposuresMutually exclusive groups of participants with epilepsy, stroke, and migraine at baseline assessment and controls (who had none of these conditions). Individuals were divided into low, moderate, or high cardiovascular risk groups based on factors that included waist to hip ratio, history of hypertension, hypercholesterolemia, diabetes, and smoking pack-years.Main Outcomes and MeasuresIncident all-cause dementia; measures of executive function; and brain total hippocampal, gray matter, and white matter hyperintensity volumes.ResultsOf 495 149 participants (225 481 [45.5%] men; mean [SD] age, 57.5 [8.1] years), 3864 had a diagnosis of focal epilepsy only, 6397 had a history of stroke only, and 14 518 had migraine only. Executive function was comparable between participants with epilepsy and stroke and worse than the control and migraine group. Focal epilepsy was associated with a higher risk of developing dementia (hazard ratio [HR], 4.02; 95% CI, 3.45 to 4.68; P < .001), compared with stroke (HR, 2.56; 95% CI, 2.28 to 2.87; P < .001), or migraine (HR, 1.02; 95% CI, 0.85 to 1.21; P = .94). Participants with focal epilepsy and high cardiovascular risk were more than 13 times more likely to develop dementia (HR, 13.66; 95% CI, 10.61 to 17.60; P < .001) compared with controls with low cardiovascular risk. The imaging subsample included 42 353 participants. Focal epilepsy was associated with lower hippocampal volume (mean difference, −0.17; 95% CI, −0.02 to −0.32; t = −2.18; P = .03) and lower total gray matter volume (mean difference, −0.33; 95% CI, −0.18 to −0.48; t = −4.29; P < .001) compared with controls. There was no significant difference in white matter hyperintensity volume (mean difference, 0.10; 95% CI, −0.07 to 0.26; t = 1.14; P = .26).Conclusions and RelevanceIn this study, focal epilepsy was associated with a significant risk of developing dementia, to a greater extent than stroke, which was magnified substantially in individuals with high cardiovascular risk. Further findings suggest that targeting modifiable cardiovascular risk factors may be an effective intervention to reduce dementia risk in individuals with epilepsy.