Background: Statin use is associated with a modest increase in the incidence of type 2 diabetes mellitus (DM) among the general population. However, HIV-infected patients have a higher risk of developing DM, and it is unclear whether statins have a diabetogenic effect in these patients. Therefore, we investigated the associations of statin use and exposure to antiretroviral drugs with type 2 DM onset in a cohort of HIV-infected patients. Methods: This retrospective, controlled, cohort study identified HIV-1-infected patients who did not have DM and were not receiving statins at their antiretroviral treatment (ART) initiation. Follow-up was accrued from ART initiation to the earliest instance of a DM diagnosis, loss to follow-up, death, or last available visit. The incidence of DM was estimated according to statin use, which was adjusted for periods without statin treatment. The Fine-Gray competing risk model was used in the multivariate analysis to identify risk factors for developing DM. Results: The analyses evaluated 6,195 patients followed for 9.8 years (interquartile range: 4.3-16.3 years). During 64,149 person-years of follow-up (PYFU), 235 patients developed DM (crude incidence: 3.66 [95%CI: 3.20-4.13] per 1,000 PYFU), and 917 (14%) patients used statins. After adjusting for potential confounders, statin use was associated with a non-significant increase in the risk of DM (AHR: 1.21, 95% CI: 0.71-2.07; P = 0.47). DM was more likely among patients who were ever treated with stavudine, and less likely among those ever treated using emtricitabine, tenofovir, abacavir, efavirenz, nevirapine, atazanavir or darunavir. Conclusions: A higher risk of diabetes mellitus was not associated with statin treatment but with traditional risk factors and stavudine use while a reduced risk of DM was associated with the use of emtricitabine, tenofovir, abacavir, efavirenz, nevirapine, atazanavir or darunavir. © 2017 The Author(s).