Abstract Background Atrial fibrillation (AF) is the most common arrhythmia and represents a significant public health burden with an increased risk of stroke, heart failure (HF) and mortality. Sodium glucose cotransporter 2 (SGLT2) inhibitors improve clinical outcomes in several populations including type 2 diabetes, chronic renal insufficiency, and HF. However, limited data exist on their effects on AF. Purpose We investigated impact of SGLT2 inhibitor on clinical outcomes compared to dipeptidyl peptidase 4 (DPP4) inhibitor among patients with type 2 diabetes and AF. Methods We conducted a retrospective cohort study using the National Health Insurance Service database. A total of 4,771 patients with type 2 diabetes and AF who were newly prescribed SGLT2 inhibitors or DPP4 inhibitors from Jan 2014 to Dec 2019 were selected and matched in a 1:2 ratio by propensity score with 38 confounding variables. We assessed the relationship of SGLT2 inhibitor with clinical outcomes including mortality, stroke, myocardial infarction (MI) and hospitalization for HF compared with DPP4 inhibitor using Cox regression model. Results Over the follow-up, 181 patients (3.7%) died, 121 patients (2.5%) were hospitalized for HF, 95 patients (2.0%) experienced MI, and 293 patients (6.1%) had stroke. Compared to DPP4 inhibitor, SGLT2 inhibitor was associated with lower risk of mortality (HR 0.61; 95% CI 0.39-0.94; P=0.025), but not of MI (HR 1.22 [95% CI 0.71-2.08]; P=0.46) or stroke (HR 1.0 [95% CI 0.75-1.33]; P=0.98). While the incidence of hospitalizations for HF tended to be lower in the SGLT2 inhibitor group, it did not reach a statistical significant level (HR 0.63 [95% CI 0.39-1.02]; P=0.06). Conclusion In a nationwide cohort of patients with type 2 diabetes and AF, SGLT2 inhibitor was associated with a lower risk of mortality compared to DPP4 inhibitor.