ObjectiveThe causal relationship between type 2 diabetes mellitus (T2DM) and osteoporosis (OS) remains unclear. This study aims to investigate the causal relationship and explore the potential metabolic mechanism and its mediating role.MethodsWe conducted a comprehensive study, gathering data on 490,089 T2DM patients from the genome-wide association study (GWAS) database and selecting OS data from FinnGen and MRC-IEU sources, including 212,778 and 463,010 patients, respectively, for causal analysis. Simultaneously, we explored the potential roles of three obesity traits and 30 metabolic and inflammation-related mediating variables in the causal relationship.ResultsThere is a strong causal relationship between T2DM and OS. The data from our two different database sources appeared in the same direction, but after correcting for body mass index (BMI), waist circumference (WC), and waist-to-hip ratio (WHR), the direction became the same. T2DM may increase the risk of OS [odds ratio (OR) > 1.5, p < 0.001]. Steiger’s test results show that there is no reverse causality. No risk factors related to glycolipid metabolism, amino acid metabolism, and inflammation were found to mediate the causal relationship.ConclusionThis study’s findings indicate a robust causal relationship between T2DM and OS, influenced by relevant factors such as BMI. Our results shed light on the pathogenesis of OS and underscore the importance for clinicians to treat metabolic disorders to prevent osteoporosis.