Innate immune signaling through the NLRP3 inflammasome is activated by multiple diabetes-related stressors, but whether targeting the inflammasome is beneficial for diabetes is still unclear. Nucleoside reverse-transcriptase inhibitors (NRTI), drugs approved to treat HIV-1 and hepatitis B infections, also block inflammasome activation. Here, we show, by analyzing five health insurance databases, that the adjusted risk of incident diabetes is 33% lower in patients with NRTI exposure among 128,861 patients with HIV-1 or hepatitis B (adjusted hazard ratio for NRTI exposure, 0.673; 95% confidence interval, 0.638 to 0.710; P < 0.0001; 95% prediction interval, 0.618 to 0.734). Meanwhile, an NRTI, lamivudine, improves insulin sensitivity and reduces inflammasome activation in diabetic and insulin resistance-induced human cells, as well as in mice fed with high-fat chow; mechanistically, inflammasome-activating short interspersed nuclear element (SINE) transcripts are elevated, whereas SINE-catabolizing DICER1 is reduced, in diabetic cells and mice. These data suggest the possibility of repurposing an approved class of drugs for prevention of diabetes.