Survivors of stroke are often concerned about cognitive problems, and information on the risk of cognitive problems often comes from small studies. We aimed to estimate years of cognitive ageing associated with stroke compared with transient ischaemic attack, myocardial infarction, and other hospitalisations in a large population. Using data from six randomised controlled trials (ORIGIN, ONTARGET, TRANSCEND, COMPASS, HOPE-3, and NAVIGATE ESUS), we completed an individual participant data meta-analysis using data requested from the Public Health Research Institute to estimate the association of stroke (by type and severity), transient ischaemic attack, myocardial infarction, and other hospitalisations with cognitive performance measured at the end of each trial. We included participants in any of these randomised controlled trials with a cognitive assessment at baseline and at least one other timepoint. Cognitive performance was measured with the Mini-Mental State Examination or the Montreal Cognitive Assessment, transformed into Z scores. We estimated Z score differences in end of trial cognitive performance between people with and without events and calculated corresponding years of cognitive ageing in these trials, and additionally calculated using a population representative cohort-the Cognitive Function and Ageing Study. In 64 106 participants from 55 countries, compared with no event, stroke was associated with 18 years of cognitive ageing (1487 strokes included in the model, 95% CI 10 to 28; p<0·0001) and transient ischaemic attack with 3 years (660 transient ischaemic attacks included in the model, 0 to 6; p=0·021). Myocardial infarction (p=0·60) and other hospitalisations (p=0·26) were not associated with cognitive ageing. The mean difference in SD compared with people without an event was -0·84 (95% CI -0·91 to -0·76; p<0·0001) for disabling stroke, and -0·12 (-0·19 to -0·05; p=0·0012) for non-disabling stroke. Haemorrhagic stroke was associated with worse cognition (-0·75, -0·95 to -0·55; p<0·0001) than ischaemic stroke (-0·42, -0·48 to -0·36; p <0·0001). Stroke has a substantial effect on cognition. The effects of transient ischaemic attack were small, whereas myocardial infarction and hospitalisation had a neutral effect. Prevention of stroke could lead to a reduction in cognitive ageing in those at greatest risk. Population Health Research Institute and Chief Scientist Office of Scotland.