Abstract Background The epidemiology of diabetes and idiopathic cardiomyopathy have limited data. We investigated the overall and the age-, sex-, and urbanization-specific incidence and relative hazard of idiopathic cardiomyopathy in association with type 2 diabetes and various anti-diabetic medications used in Taiwan. Methods A total of 474,268 patients with type 2 diabetes were identified from ambulatory care and inpatient claims in 2007–2009 from Taiwan’s National Health Insurance (NHI) database. We randomly selected 474,266 age-, sex-, and diagnosis date-matched controls from the registry of NHI beneficiaries. All study subjects were linked to ambulatory care and inpatient claims (up to the end of 2016) to identify the possible diagnosis of idiopathic cardiomyopathy. The person-year approach with Poisson assumption was used to estimate the incidence, and Cox proportional hazard regression model with Fine and Gray’s method was used to estimate the relative hazards of idiopathic cardiomyopathy in relation to type 2 diabetes. Results The overall incidence of idiopathic cardiomyopathy for men and women patients, respectively, was 3.83 and 2.94 per 10,000 person-years, which were higher than the corresponding men and women controls (2.00 and 1.34 per 10,000 person-years). Compared with the control group, patients with type 2 diabetes were significantly associated with an increased hazard of idiopathic cardiomyopathy (adjusted hazard ratio [aHR]: 1.60, 95% confidence interval [CI]: 1.45–1.77] in all age and sex stratifications except in those men aged > 64 years. Patients with type 2 diabetes aged 64 years. Younger patients were vulnerable to have higher HRs of idiopathic cardiomyopathy. Some anti-diabetic medications may reduce the risks of cardiomyopathy.