BackgroundStroke is a common cerebrovascular disease with great danger to public health. Educational inequality is a universal issue that influences populations’ stroke risk. This study aimed to investigate the causal relationship between education and stroke risk and the contributions of effects mediated by four modifiable factors.Materials and methodsPublic large-scale genome-wide association study (GWAS) summary data associated with educational attainment, hypertensive diseases, body mass index (BMI), smoking behavior, time spent on watching the television (TV), and stroke were obtained from European ancestry. The data were used to investigate the causal relationship among educational attainment, hypertensive disease, BMI, smoking, watching TV, and stroke risk. Inverse variance weighted (IVW) method was used as a primary algorithm for estimating causal direction and effect size in univariable and multivariable Mendelian randomization (MR) analyses.ResultsHigher educational attainment was a causal protective factor, while hypertensive diseases, higher BMI, smoking, and longer time spent on watching the TV were all causal risk factors for the risk of stroke. Hypertensive disease, BMI, smoking, and watching TV were all mediators for linking the causal relationship between educational attainment and stroke risk. Hypertensive disease, BMI, smoking, and watching TV explained 47.35%, 24.74%, 15.72%, and 2.29% of the variance in educational attainment’s effect on stroke risk, respectively. The explained proportion reached 69.32% after integrating the four factors.ConclusionsThese findings support the causal effect of educational attainment on the risk of stroke, with a substantial proportion mediated by modifiable risk factors. Interventions on these modifiable factors would lead to substantial reductions in stroke cases attributable to educational inequality.Supplementary InformationThe online version contains supplementary material available at 10.1186/s13041-023-01030-0.