Integrase strand transfer inhibitors (INSTI) are associated with weight gain in people with HIV (PWH), but their impact on diabetes is unclear. We evaluated the association between switching from nonnucleoside reverse-transcriptase inhibitors (NNRTI) or protease inhibitors (PI) to INSTI and incident diabetes. Longitudinal cohort study. We included PWH aged ≥18 years from the Johns Hopkins HIV Clinical Cohort (2007-2023) without history of diabetes who had used NNRTI or PI for ≥180 days. We followed participants up to 10 years from HIV primary care visits where they switched to INSTI or continued NNRTI or PI. We estimated the hazard of incident diabetes associated with switching to INSTI using weighted Cox regression with robust variance estimator. We included 2075 PWH who attended 22 116 visits where they continued NNRTI or PI and 631 visits where they switched to INSTI. Switching to INSTI was associated with a weighted hazard ratio (wHR) of 1.11 [95% confidence interval (CI), 0.77-1.59] for incident diabetes. The association if no weight gain occurred during the first two years was not qualitatively different (wHR 1.22; 95% CI, 0.82-1.80). In a posthoc analysis, switching to INSTI conferred a significant wHR of 1.79 (95% CI, 1.13-2.84) for diabetes within the first two years but not after. Switching from NNRTI or PI to INSTI did not significantly increase overall diabetes incidence in PWH, although there may be elevated risk in the first two years. These findings can inform considerations when switching to INSTI-based regimens.