Background: Understanding the causal relations between dietary habits and stroke is crucial for prioritizing public health interventions and developing effective health strategies. This study utilized Mendelian randomization (MR) analysis to examine the causal associations between 20 dietary habits and various stroke subtypes, aiming to identify potential mediators and evaluate the proportions of mediation. Methods: A two-sample MR analysis was conducted to examine the causal relationships between dietary habits and stroke incidence. Mediation analysis, two-step MR (TSMR), and multivariable MR (MVMR) were employed to identify potential mediators. Genetic data pertaining to dietary habits and stroke were obtained from extensive genome-wide association study (GWAS) consortia. The inverse variance-weighted (IVW) method served as the primary analytical approach, with the additional scrutiny of significant correlations conducted through the Egger regression, MR-Pleiotropy Residual Sum and Outlier (MR-PRESSO), and weighted median techniques. Results: Our analyses indicated that genetically predicted intakes of dried fruits, cheese, cereal, oily fish, and hot drink temperatures were protective against stroke, whereas higher intakes of lamb/mutton, poultry, and added salt significantly elevated stroke risk. Specifically, dried fruit consumption demonstrated a protective effect against total stroke (β = −0.009, p = 0.013), ischemic stroke (β = −0.475, p = 0.003), and small-vessel ischemic stroke (β = −0.682, p = 0.033) through reductions in BMI levels, accounting for mediated proportions of 3.2%, 17.1%, and 8.5%, respectively. Furthermore, cheese intake provided a protective effect against ischemic stroke (β = −0.275, p = 0.003) by decreasing BMI and increasing HDL-C levels, with mediated proportions of 30.5% and 6.5%. Together, BMI and HDL-C accounted for 34.9% of the beneficial effect of cheese intake on reducing the risk of ischemic stroke. In contrast, an increased salt intake exhibited a positive association with large-artery ischemic stroke (β = 0.432, p = 0.033) through BMI elevation, with a mediated proportion of 10.9%. Conclusions: Our findings provide compelling evidence supporting causal relationships between dietary habits and stroke subtypes, while identifying mediators and evaluating the proportions of mediation. Adhering to a low-calorie, nutrient-dense diet enriched with dried fruits, cheese, and cereal, along with reduced salt and poultry consumption, could potentially mitigate stroke risk.