Thyroid function may alter carbohydrate metabolism via influence of insulin, which may in terms of derangement of thyroid function and insulin function result in the development of type 2 diabetes mellitus (T2D). We investigated the association of thyroid disorders with T2D by a cohort study of the Taiwan nationwide health insurance database.A sub-dataset of the National Health Insurance Research Database (NHIRD) was used in this study. The thyroid disease (both hyper- and hypo-thyroidism) group was chosen from patients older than 18 years and newly diagnosed between 2000 and 2012. The control group consisted of randomly selected patients who never been diagnosed with thyroid disease and 4-fold size frequency matched with the thyroid disease group. The event of this cohort was T2D (ICD-9-CM 250.x1, 250.x2). Primary analysis was performed by comparing the thyroid disease group to the control group and the second analysis was performed by comparing the hyperthyroidism subgroup, hypothyroidism subgroup, and control group.The occurrence of T2D in the thyroid disease group was higher than the control group with hazard ratio (HR) of 1.23 [95% confidence interval (CI) = 1.16-1.31]. Both hyperthyroidism and hypothyroidism were significantly higher than control. Significantly higher HR was also seen in female patients, age category of 18 to 39-year-old (y/o) and 40 to 64 y/o subgroups. Higher occurrence of T2D was also seen in thyroid disease patients without comorbidity than in the control group with HR of 1.47 (95% CI = 1.34-1.60). The highest HR was found in the half-year follow-up.There was a relatively high risk of T2D development in patients with thyroid dysfunctions, especially in the period of 0.5 to 1 year after presentation of thyroid dysfunctions. The results suggest performing blood sugar tests in patients with thyroid diseases for early detection and treatment of T2D.