Limited evidence exists to support any specific medication over others to prevent dementia in older patients with type 2 diabetes (T2D). We investigated whether treatment with sodium-glucose cotransporter 2 (SGLT-2) inhibitors is associated with a lower risk of incident dementia and all-cause mortality, relative to dipeptidyl peptidase-4 (DPP-4) inhibitors and glucagon-like peptide-1 receptor agonists (GLP-1 RA). In this retrospective, active-comparator cohort study, we used data from the TriNetX electronic health records network. Our primary cohort comprised patients with T2D aged ≥50 years, registered between January 2012 and December 2022. Patients with a history of dementia were excluded. We used Kaplan-Meier survival analysis to estimate the incidence of dementia and all-cause mortality in our cohort after they had used glucose-lowering drugs for at least 12 months. Propensity score matching was performed to balance the SGLT-2 inhibitor, DPP-4 inhibitor and GLP-1 RA cohorts. Subgroup analyses for sex and age were also conducted. Our first cohort comprised 193 948 patients treated with metformin and SGLT-2 inhibitors and an equal number of patients treated with metformin and DPP-4 inhibitors. In this cohort, the risk of dementia and all-cause mortality was lower in patients treated with SGLT-2 inhibitors than in those treated with DPP-4 inhibitors (hazard ratio [HR]: 0.62, 95% confidence interval [CI]: 0.59-0.65, for dementia; HR: 0.54, 95% CI: 0.52-0.56, for all-cause mortality). Our second cohort comprised 165 566 patients treated with metformin and SGLT-2 inhibitors and an equal number of patients treated with metformin and GLP-1 RAs. In this cohort, the risk of dementia and all-cause mortality was lower in those treated with SGLT-2 inhibitors than in those treated with GLP-1 RAs (HR: 0.92, 95% CI: 0.87-0.98, for dementia; HR: 0.88, 95% CI: 0.85-0.91, for all-cause mortality). The use of SGLT-2 inhibitor was associated with a lower risk of incident dementia and all-cause mortality in older adults with T2D compared to DPP-4 inhibitor and GLP-1 RA.