To emulate target trials comparing recurrence of nephrolithiasis among patients with pre-existing nephrolithiasis (overall and stratified by concomitant gout) initiating sodium-glucose cotransporter-2 (SGLT-2) inhibitors versus an active comparator. Target trial emulation studies. Canadian population database, January 2014 to June 2022. 20 146 patients with nephrolithiasis and type 2 diabetes, including those with concomitant gout at baseline, a high risk group. Initiation of an SGLT-2 inhibitor or glucagon-like peptide-1 (GLP-1) receptor agonist, with a dipeptidyl peptidase-4 (DPP-4) inhibitor as alternative comparator. The primary outcome was recurrent nephrolithiasis events ascertained from diagnoses during emergency department visits, hospital admissions, or outpatient visits. Secondary outcomes included nephrolithiasis resulting in hospital admission or emergency department visits and flare-up of gout, as well as a positive control outcome (genital infection) and negative control outcomes (osteoarthritis encounter and appendicitis). Poisson and Cox proportional hazards regression models were used (primary analyses), as well as overlap weighting. After inverse probability of treatment weighting, 1924 recurrent nephrolithiasis events occurred among the 14 456 weighted patients who used an SGLT-2 inhibitor (105.3 per 1000 person years), compared with 853 events among the 5877 weighted patients who used a GLP-1 receptor agonist (156.4 per 1000 person years). The adjusted rate ratio was 0.67 (95% confidence interval (CI) 0.57 to 0.79) and rate difference was -51 (95% CI -63 to -40) per 1000 person years, with a number needed to treat (NNT) of 20. Among those with recently active nephrolithiasis, the absolute rate difference was 219 per 1000 person years (NNT of 5). Protective associations persisted for nephrolithiasis events that required emergency department visits, hospital admissions, or procedures, and when an SGLT-2 inhibitor was compared with a DPP-4 inhibitor (rate ratio 0.73 (0.68 to 0.78), rate difference -38 (-46 to -29) per 1000 person years (NNT of 26)). Protective associations also persisted among patients with nephrolithiasis and concomitant gout, with a rate ratio of 0.67 (0.57 to 0.79) and rate difference of -53 (95% CI -78 to -27) per 1000 person years versus a GLP-1 receptor agonist (NNT of 19), and 0.63 (0.55 to 0.72) and-62 (-81 to -42) per 1000 person years, respectively, versus a DPP-4 inhibitor (NNT of 16). Furthermore, SGLT-2 inhibitor use was associated with a lower rate of gout flare-ups (rate ratio 0.72, 0.54 to 0.95, rate difference -16, -31 to -1 per 1000 person years) compared with GLP-1 receptor agonists (0.65, 0.52 to 0.82, and -21, -33 to -9 per 1000 person years) compared with DPP-4 inhibitors. SGLT-2 inhibitor initiators showed higher risk of genital infection (eg, hazard ratio 2.21, 95% CI 1.68 to 2.90, and rate difference 13 per 1000 person years), but no altered risk of osteoarthritis encounter (0.87, 0.68 to 1.1, and -2 per 1000 person years) or appendicitis (1.07, 0.69 to 1.67, and 1 per 1000 person years). Results were similar when propensity score overlap weighting was applied. The benefits associated with SGLT-2 inhibitor for patients with nephrolithiasis in these target trial emulations suggest they may be a useful addition to current treatments to simultaneously manage nephrolithiasis recurrence and comorbidities, including gout.