Cognitive impairment and dementia are highly prevalent among stroke survivors and represent a major burden for patients, carers, and health-care systems. We studied the risk factors for post-stroke cognitive impairment (PSCI) and dementia (PSD) beyond the well established risk factors of age and stroke severity. In this systematic review and meta-analysis we conducted a systematic literature search from database inception until Sept 15, 2023. We selected prospective and retrospective cohort studies, post-hoc analyses from randomised controlled trials, and nested case-control studies of patients with acute stroke (ischaemic, haemorrhagic, and transient ischaemic attack), exploring associations between risk factors at baseline and PSCI or PSD over a follow-up period of at least 3 months. Study quality was assessed using the Newcastle-Ottawa quality assessment scale. We calculated pooled relative risks (RRs) with random-effects meta-analyses and performed subgroup, meta-regression, and sensitivity analyses. This study was preregistered with PROSPERO, CRD42020164959. We identified 162 eligible articles for our systematic review, of which 113 articles (89 studies, 160 783 patients) were eligible for meta-analysis. Baseline cognitive impairment was the strongest risk factor for PSCI (RR 2·00, 95% CI 1·66-2·40) and PSD (3·10, 2·77-3·47). We identified diabetes (1·29, 1·14-1·45), presence or history of atrial fibrillation (1·29, 1·04-1·60), presence of moderate or severe white matter hyperintensities (WMH; 1·51, 1·20-1·91), and WMH severity (1·30, 1·10-1·55, per SD increase) as treatable risk factors for PSCI, independent of age and stroke severity. For PSD, we identified diabetes (1·38, 1·10-1·72), presence of moderate or severe WMH (1·55, 1·01-2·38), and WMH severity (1·61, 1·20-2·14, per SD increase) as treatable risk factors. Additional risk factors included lower educational attainment, previous stroke, left hemisphere stroke, presence of three or more lacunes, brain atrophy, and low baseline functional status. Associations of risk factors with PSD were weaker in studies conducted and published more recently. We found substantial interstudy heterogeneity and evidence of reporting bias. Our results highlight the importance of cognitive impairment in the acute phase after stroke for long-term prediction of PSCI and PSD. Treatable risk factors include diabetes, atrial fibrillation, and markers of cerebral small vessel disease (ie, white matter hyperintensities and lacunes). Future trials should explore these risk factors as potential targets for prevention of PSCI and PSD. German Research Foundation.