Patients with diverticular disease (DD) have ongoing chronic inflammation associated with changes in the gut microbiome, which might contribute to the development of dementia. Using Danish medical and administrative registries from 1980 to 2013, we conducted a nationwide population-based cohort study including all DD patients and a matched (5:1) general population comparison cohort without DD. A nested case-control analysis was then conducted using a risk set sampling, matching four DD controls without dementia to each DD patient with dementia. Clinical severity was categorized as uncomplicated DD (outpatient), conservatively treated DD (inpatient), and surgically treated DD. 149 527 DD patients and 747 635 general population comparators were identified. The 30-year cumulative incidence of dementia among DD patients and general population comparators were 12.4 (95% confidence interval [CI] 12.1-12.7) and 13.73% (95% CI 13.6-13.9), respectively. This corresponded to a 30-year hazard ratio (HR) of 1.10 (95% CI 1.1-1.1). The highest HRs were found in the conservatively treated DD group (1.15 95% CI 1.1-1.2) and the group with young onset of DD (1.52 95% CI 1.2-2.0). In the nested case-control analysis, we identified 8875 dementia cases and 35 491 matched controls. The adjusted odds ratio (OR) for conservatively treated DD was increased (1.08, 95% CI; 1.0-1.2) compared to the reference of uncomplicated DD. We observed a slight increased risk of dementia in patients with young onset DD and conservatively treated DD. Findings suggest an association between disease duration, perhaps reflecting the duration of gut inflammation, and the risk of developing dementia.