BACKGROUND: We examined the real-world comparative safety of sodium-glucose cotransporter-2 inhibitors (SGLT2i) vs. other newer anti-glycemic medications (dipeptidyl peptidase-4 inhibitors [DPP4i], glucagon-like peptide-1 receptor agonists [GLP1a]) in patients with and without chronic kidney disease (CKD). METHODS: Among US Veterans with diabetes receiving care from the Veterans Affairs (VA) healthcare system over 2004-19, we identified incident users of SGLT2i vs. DPP4i vs. GLP1a monotherapy. In analyses stratified by CKD status, defined by estimated glomerular filtration rate and albuminuria, we examined associations of SGLT2i vs. DPP4i vs. GLP1a use with risk of infection-related (primary outcome) and genitourinary infection hospitalizations (secondary outcome) using multivariable Cox models. FINDINGS: Among 92,269 patients who met eligibility criteria, 52% did not have CKD, whereas 48% had CKD. In the overall and non-CKD cohorts, compared to DPP4i use, SGLT2i use was associated with lower infection-related hospitalization risk (HRs [95% CIs] 0.74 [0.67-0.81] and 0.77 [0.67, 0.88], respectively), whereas GLP1a use demonstrated comparable risk. However, in the CKD cohort SGLT2i and GLP1a use were each associated with lower risk (HRs [95% CIs] 0.70 [0.61, 0.81] and 0.91 [0.84, 0.99], respectively). Propensity score-matched analyses showed similar findings in the non-CKD and CKD cohorts. In the overall, non-CKD, and CKD cohorts, SGLT2i use was associated with lower genitourinary infection hospitalization risk whereas GLP1a use showed comparable risk vs. DPP4i use. INTERPRETATION: In a national cohort of Veterans with diabetes, compared with DPP4i use, SGLT2i use was associated with lower infection-related and genitourinary infection hospitalization risk. FUNDING: VA Health Services Research and Development, USA.