Benzodiazepines and Z-drugs are two of the most prescribed agents worldwide. However, because of their cognitive side effects, the question of their influence on the risk of dementia has been raised. The authors examined the association of benzodiazepines, Z-drugs, and other anxiolytics with incident dementia in patients with affective disorders.The authors conducted a cohort and nested case-control study of 235,465 patients over age 20 who were identified in the Danish National Patient Registry as having had a first-time hospital contact for an affective disorder between 1996 and 2015. From the Danish National Prescription Registry, information was obtained on all prescriptions for benzodiazepines, Z-drugs, and other anxiolytics, and patients were followed for incident dementia (defined by hospital discharge diagnosis or acetylcholinesterase inhibitor use). Cox proportional hazards and conditional logistic regression models were used to calculate hazard ratios and odds ratios with adjustment for sociodemographic and clinical variables.A total of 75.9% (N=171,287) of patients had any use of benzodiazepines or Z-drugs, and during the median follow-up of 6.1 years (interquartile range, 2.7-11), 9,776 (4.2%) patients were diagnosed with dementia. Any use of benzodiazepines or Z-drugs showed no association with dementia after multiple adjustments in either the cohort analysis or a nested case-control design. In the cohort analysis, the number of prescriptions and the cumulated dose of benzodiazepines or Z-drugs at baseline were not associated with dementia. In the nested case-control study, where prescriptions were counted from 1995 until 2 years before the index date, there was a slightly higher odds ratio of dementia in patients with the lowest use of benzodiazepines or Z-drugs (odds ratio=1.08, 95% CI=1.01, 1.15) compared with no lifetime use. However, patients with the highest use had the lowest odds of developing dementia (odds ratio=0.83, 95% CI=0.77, 0.88).This large cohort study did not reveal associations between use of benzodiazepines or Z-drugs and subsequent dementia, even when exposures were cumulated or divided into long- and short-acting drugs. Some results were compatible with a protective effect.