Background Antihyperglycemic drugs have been linked to new-onset atrial fibrillation (NAF). However, the effect of the different classes of antihyperglycemic drugs on the development of NAF in elderly patients has not been well studied. In this study, we investigated the association between different classes of antihyperglycemic drugs and NAF in elderly patients Materials and methods This was a nested case-control study performed using the database of National Health Insurance programme in Taiwan. Each participant aged 65 years and older who were NAF from 2005 to 2012 were assigned to the NAF group, whereas case was sex-, age-, diabetes duration-, index date-matched, and Charlson Comorbidity Index score-matched randomly selected participant without NAF were assigned to the non-NAF group. Multivariable logistic regression model was used for the estimation of odds ratios (ORs) and 95% confidence intervals (CIs) of NAF associated with use of different classes of antihyperglycemic agents. Nonusers served as the reference group. Results We identified 1958 cases and 7832 controls. The risk of NAF after adjusting for sex, age, comorbidities and concurrent medication was higher among the users of insulin than among the nonusers (OR, 158; 95% CI, 137-182). Patients who took dipeptidyl peptidase 4 inhibitors were at lower risk of developing NAF than the nonusers (OR, 065; 95% CI, 045-093). Conclusions In this population, use of dipeptidyl peptidase 4 inhibitor was associated with a low risk of NAF. Insulin use was associated with a significant increase in the risk of NAF during the long-term follow-up.