REPRIEVE (Randomized Trial to Prevent Vascular Events in HIV) led to new guidelines for statin use among people with HIV (PWH) with low to moderate risk for atherosclerotic cardiovascular disease (ASCVD). Little is known about the natural history of diabetes mellitus (DM) or mechanisms contributing to statin effects on DM among this population. To determine the contribution of known DM risk factors to excess risk for DM with pitavastatin in REPRIEVE. Phase 3, primary ASCVD prevention trial over a median of 5.6 years of follow-up. (ClinicalTrials.gov: NCT02344290). Global, multicenter trial. 7731 PWH aged 40 to 75 years with low to moderate ASCVD risk (by the pooled cohort equations from the American College of Cardiology and American Heart Association) without DM at study entry. Random 1:1 assignment to pitavastatin, 4 mg daily, or placebo. New-onset DM was determined at each visit by clinical diagnosis requiring initiation of medication treatment for DM. The incidence of new-onset DM was assessed in relation to predefined demographic and metabolic risk factors, stratified by treatment group. Treatment effects of pitavastatin on progression to new DM in key subgroups were determined. Participants with at least 3 DM risk factors (vs. no risk factors) had increased risk for DM in each treatment group (incidence rate, 3.24 per 100 person-years [PY] vs. 0.34 per 100 PY [pitavastatin] and 2.66 per 100 PY vs. 0.27 per 100 PY [placebo]). The incidence of DM was highest in South Asia. In adjusted analyses, high body mass index, prediabetes, and metabolic syndrome components were strongly associated with new-onset DM (all P < 0.005). Pitavastatin was the only statin assessed; DM was assessed clinically. Metabolic risk factors, including prediabetes and obesity, contributed to new-onset DM in statin- and placebo-treated participants. A clinically significant effect of pitavastatin on DM was seen primarily among those with multiple risk factors for DM at entry. Strategies targeting key metabolic risk factors, like obesity and prediabetes, may help protect against DM among PWH. National Heart, Lung, and Blood Institute of the National Institutes of Health.