Cognitive impairment is a common feature of multiple sclerosis (MS) and neuromyelitis optica spectrum disorder (NMOSD). However, there is a lack of population-based study of dementia risk in these disorders. In the present study, the risk of dementia in MS and NMOSD patients in Republic of Korea was estimated. Data analyzed in this study were obtained from the Korean National Health Insurance Service (KNHIS) database between January 2010 and December 2017. The study included 1,347 MS patients and 1,460 NMOSD patients ≥40 years of age who had not been diagnosed with dementia within 1 year prior to the index date. Matched controls were selected based on age, sex, and the presence of hypertension, diabetes mellitus, or dyslipidemia. In MS and NMOSD patients, the risk of developing any dementia [adjusted hazard ratio (aHR) = 2.34; 95% confidence interval (CI) = 1.84-2.96 and aHR = 2.19; 95% CI = 1.61-3.00, respectively], Alzheimer's disease [AD; aHR = 2.23; 95% confidence interval (CI) = 1.70-2.91 and aHR = 1.99; 95% CI = 1.38-2.88, respectively], and vascular dementia (aHR = 3.75; 95% CI = 1.91-7.35 and aHR = 3.21; 95% CI = 1.47-7.02, respectively) was higher compared with the matched controls. NMOSD patients had a lower risk of any dementia and AD compared with MS patients after adjusting for age, sex, income, hypertension, diabetes, and dyslipidemia (aHR = 0.67 and 0.62). The risk of dementia increased in MS and NMOSD patients and dementia risk was higher in MS than in NMOSD.