Current evidence is inconclusive on cognitive benefits or harms of statins among stroke patients, who have high risk of dementia. This observational cohort study investigated the association between statin use and post-stroke dementia using data from the Clinical Practice Research Datalink. Patients without prior dementia who had an incident stroke but received no statins in the preceding year were followed for up to 10 years. We used inverse probability weighted marginal structural models to estimate observational analogues of intention-to-treat (ITT, statin initiation vs. no initiation) and per-protocol (PP, sustained statin use vs. no use) effects on the risk of dementia. To explore potential impact of unmeasured confounding, we examined the risks of coronary heart disease (CHD, positive control outcome), fracture and peptic ulcer (negative control outcomes). In 18,577 statin initiators and 14,613 non-initiators (mean follow-up of 4.2 years), the adjusted hazard ratio (aHR) for dementia was 0.70 (95% confidence interval [CI] 0.64-0.75) in ITT analysis and 0.55 (95% CI 0.50-0.62) in PP analysis. The corresponding aHR and aHR were 0.87 (95% CI 0.79-0.95) and 0.70 (95% CI 0.62-0.80) for CHD, 1.03 (95% CI 0.82-1.29) and 1.09 (95% CI 0.77-1.54) for peptic ulcer, and 0.88 (95% CI 0.80-0.96) and 0.86 (95% CI 0.75-0.98) for fracture. Statin initiation after stroke was associated with lower risk of dementia, with a potentially greater benefit in patients who persisted with statins over time. The observed association of statin use with post-stroke dementia may in part be overestimated due to unmeasured confounding shared with the association between statin use and fracture.