Background: Cognitive impairment is an important consequence of stroke and transient ischaemic attack, but its determinants are not fully understood. Simple univariable or multivariable models have not shown clinical utility for predicting cognitive impairment. Cardiovascular risk factors may influence cognition through multiple, direct, and indirect pathways, including effects on prior cognition and stroke severity. Understanding these complex relationships may help clinical teams plan intervention and follow-up strategies. Methods: We analysed clinical and demographic data from consecutive patients admitted to an acute stroke ward. Cognitive assessment comprised Abbreviated Mental Test and mini-Montreal Cognitive Assessment. We constructed bias-corrected confidence intervals to test indirect effects of cardiovascular risk factors (hypertension, vascular disease, atrial fibrillation, diabetes mellitus, previous stroke) on cognitive function, mediated through stroke severity and history of dementia, and we assessed moderation effects due to comorbidity. Results: From 594 eligible patients, we included 587 in the final analysis (age range 26-100; 45% female). Our model explained R 2 = 62.10% of variance in cognitive test scores. We found evidence for an indirect effect of previous stroke that was associated with increased risk of prevalent dementia and in turn predicted poorer cognitive score (estimate = − 0.39; 95% bias-corrected CI, − 0.75 to − 0.13; p = 0.02). Atrial fibrillation was associated with greater stroke severity and in turn with a poorer cognitive score (estimate = − 0.27; 95% bias-corrected CI, − 0.49 to − 0.05; p = 0.02). Conversely, previous TIA predicted decreased stroke severity and, through that, lesser cognitive impairment (estimate = 0.38; 95% bias-corrected CI, 0.08 to 0.75; p = 0.02). Through an association with reduced stroke severity, vascular disease was associated with lesser cognitive impairment, conditional on presence of hypertension and absence of diabetes mellitus (estimate = 0.36; 95% bias-corrected CI, 0.03 to 0.68; p = 0.02), although the modelled interaction effects did not reach statistical significance.