BACKGROUND: To confirm whether type 2 diabetes (T2DM) is an affective disorder (AD) precursor, and to establish possible effects of oral anti-hyperglycemic agents (OAAs). METHODS: A representative cohort of 800,000 subjects was obtained from the Taiwanese National Health Insurance database on 1 January 2000. Those with consistent data (n = 762,753) were followed up between 1 January 1996 and 31 December 2007. Over this period, we assessed the presence (n = 62,988) or absence (n = 699,795) of T2DM, and whether any OAA was used (n = 40,232) or not (n = 22,756). To compare the risk of AD by diabetic status, those with T2DM were matched for birth date and gender with those without T2DM. To assess the effect of OAAs, we considered those 50 years and over. Matched AD-free patients with T2DM on OAAs were compared with those without OAAs, for age, gender, locality, health service, Charlson Comorbidity Index. and diabetes diagnosis date to avoid immortal time bias. AD incidence densities, hazard ratios (HR) and 95% confidence intervals (CIs) were calculated. RESULTS: Compared with diabetes-free subjects, the HR (95% CI) for AD was 2.62 (2.31 to 2.98) for patients with T2DM who were not on OAAs, and 1.08 (0.99 to 1.18) for those who were on OAAs. The AD incidence density decreased from 91.1 to 39.4 per 10,000 person-years for patients on the combination of metformin and sulfonylurea. The HR (95% CI) for AD was 0.92 (0.59 to 1.45) for those on metformin alone, 1.08 (0.84 to 1.38) for those on sulfonylurea alone, and 0.40 (0.32 to 0.50) for the combined treatment, and the decrease was not related to sequence or insulin usage. Similar patterns were seen for incident AD exclusion for up to 3 years, although more so for bipolar than unipolar. CONCLUSIONS: The incident AD risk is increased by 2.6-fold in T2DM, and the combination of sulfonylurea and metformin minimizes this risk.