BackgroundType 2 diabetes mellitus (DM2) and osteoporosis (OP) are currently the two most significant causes of mortality and morbidity in older adults, according to clinical evidence. The intrinsic link between them is yet unknown, despite reports of their coexistence. By utilizing the two-sample Mendelian randomization (MR) approach, we sought to evaluate the causal impact of DM2 on OP.MethodsThe aggregate data of the whole gene-wide association study (GWAS) were analyzed. A two-sample MR analysis was performed using single-nucleotide polymorphisms (SNPs), which are strongly associated with DM2, as instrumental variables (IVs) to evaluate the causal analysis of DM2 on OP risk with OR values, using inverse variance weighting, MR-egger regression, and weighted median methods, respectively.ResultA total of 38 single nucleotide polymorphisms were included as tool variables. According to the results of inverse variance-weighted (IVW), we found that there was a causal relationship between DM2 and OP, in which DM2 had a protective effect on OP. For each additional case of DM2, there is a 0.15% decrease in the odds of developing OP (OR = 0.9985;95%confidence interval:0.9974,0.9995;Pvalue = 0.0056). There was no evidence that the observed causal effect between DM2 and the risk of OP was affected by genetic pleiotropy (P= 0.299). Using Cochran Q statistics and MR-Egger regression in the IVW approach, the heterogeneity was calculated;P> 0.05 shows that there is a significant amount of heterogeneity.ConclusionA causal link between DM2 and OP was established by MR analysis, which also revealed that DM2 decreased the occurrence of OP.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12891-023-06528-1.