ObjectiveThe relationship between diabetes mellitus (DM) and autism spectrum disorder (ASD) remains controversial. This study aimed to analyze the causal relationship between different types of DM and ASD by bidirectional Mendelian randomization (MR).MethodsSingle nucleotide polymorphisms for type 1 diabetes mellitus (T1DM), type 2 diabetes mellitus (T2DM), gestational diabetes mellitus (GDM), and ASD were obtained from genome-wide association studies. Subsequently, inverse variance weighted, MR-Egger, and weighted median were used to test the exposure-outcome causality. Finally, MR-Egger’s intercept, Cochran’s Q, and leave-one-out method were used to assess horizontal pleiotropy, heterogeneity, and sensitivity of the results, respectively.ResultsThe positive analysis showed that T2DM was associated with an increased risk of ASD, whereas neither T1DM nor GDM was associated with the risk of ASD. The reverse analysis showed that ASD was associated with an increased risk of T2DM, while it was not associated with the risk of either T1DM or GDM. MR-Egger intercept showed no horizontal pleiotropy (p > 0.05) for these results. Cochran’s Q showed no heterogeneity expect for the results of T1DM on the risk of ASD, and leave-one-out sensitivity analysis showed these results were robust.ConclusionThis MR analysis suggests that T2DM and ASD are reciprocal risk factors and that they may create an intergenerational risk cycling in female patients. Aggressive prevention and treatment of T2DM and ASD help to break the trap of this risk cycling. Additionally, this study does not support a causal relationship between T1DM and ASD, as well as GDM and ASD. And more studies are needed in the future to continue to explore the interactions and underlying mechanisms between different types of DM and ASD.