ImportanceMetformin may have a protective association against developing osteoarthritis (OA), but robust epidemiological data are lacking.ObjectiveTo determine the risk of OA and joint replacement in individuals with type 2 diabetes treated with metformin compared with a sulfonylurea.Design, Setting, and ParticipantsThis retrospective cohort study used claims data from the Optum deidentified Clinformatics Data Mart Database between December 2003 and December 2019. Participants included individuals aged 40 years or older with at least 1 year of continuous enrollment and type 2 diabetes. Individuals with type 1 diabetes or a prior diagnosis of OA, inflammatory arthritis, or joint replacement were excluded. Time-conditional propensity score matching was conducted using age, sex, race, Charlson comorbidity score, and treatment duration to create a prevalent new-user cohort. Data were analyzed from April to December 2021.ExposuresTreatment with metformin or a sulfonylurea.Main Outcomes and MeasuresThe outcomes of interest were incident OA and joint replacement. Cox proportional hazard models were used to calculate adjusted hazard ratios (aHRs) of incident OA and joint replacement. In a sensitivity analysis, individuals only ever treated with metformin were compared with individuals only ever treated with a sulfonylurea, allowing for longer-term follow up of the outcome (even after stopping the medication of interest).ResultsAfter time-conditional propensity score matching, the metformin and control groups each included 20 937 individuals (mean [SD] age 62.0 [11.5] years; 24 379 [58.2%] males). In the adjusted analysis, the risk of developing OA was reduced by 24% for individuals treated with metformin compared with a sulfonylurea (aHR, 0.76; 95% CI, 0.68-0.85; P < .001), but there was no significant difference for risk of joint replacement (aHR, 0.80; 95% CI, 0.50-1.27; P = .34). In the sensitivity analysis, the risk of developing OA remained lower in individuals treated with metformin compared with a sulfonylurea (aHR, 0.77; 95% CI, 0.65-0.90; P < .001) and the risk of joint replacement remained not statistically significant (aHR, 1.04; 95% CI, 0.60-1.82; P = .89).Conclusions and RelevanceIn this cohort study of individuals with diabetes, metformin treatment was associated with a significant reduction in the risk of developing OA compared with sulfonylurea treatment. These results further support preclinical and observational data that suggest metformin may have a protective association against the development of OA; future interventional studies with metformin for the treatment or prevention of OA should be considered.