This study aimed to determine the association between statins and the prevention of dementia according to sex differences in elderly patients with ischemic heart disease (IHD). We performed a nationwide retrospective cohort study using the Korean Health Insurance Review and Assessment Service database (2007-2015). Among the 264,036 eligible patients aged >/=65 years with IHD, statin users were compared with non-users by propensity score matching at a 1:1 ratio (71,587 in each group). The primary outcome was dementia risk by estimating hazard ratios (HRs) and 95% confidence intervals (CIs). Differential risks of dementia were assessed by sex in the subgroups of statin types, exposure duration, and patient age, implying that sex is an influential factor for the link between statin use and dementia incidence. Among seven commonly prescribed statins, rosuvastatin was associated with the greatest preventive effect on dementia incidence, with an adjusted HR of 0.82 (95% CI = 0.78-0.87). In a subgroup analysis organized by sex, the differential risk of dementia incidence was assessed in each statin group, implying that sex is an influential factor for the link between statin and dementia. This study suggests that appropriate statin use considering sex differences may have beneficial effects on the development of dementia.