Poor glycemic control is related to an increased risk of endstage renal disease (ESRD). This study investigated the association between medication adherence and the risk of ESRD in patients with newly diagnosed diabetes mellitus. In this population-based cohort study, we used the TaiwanNational Health Insurance Research Database (NHIRD) to identify 559,864 patients with newly diagnosed or treated diabetes mellitus who were ages from 20 to 85 years between 2001 and 2008. We identified 1695 patients with ESRD during the study period. The mean follow-up time of the patients with ESRD was 5.7 years. Time-dependent Cox proportional hazards regression was performed to estimate the hazard ratios for ESRD among the patients with newly diagnosed diabetes mellitus. After adjustment for various covariates, nonadherence to oral antihyperglycemic medication (OAM) was associated with a higher risk of ESRD compared with adherence to OAM (hazard ratio [HR], 1.11; 95% confidence interval [CI], 1.01-1.23). The effects of nonadherence to OAM on the risk of ESRD were significant for patients without hypertension, without gout, without chronic kidney disease, undergoing OAM polytherapy, and undergoing metformin polytherapy (HR [95% CIs], 1.18 [1.00-1.39], 1.13 [1.02- 1.26], 1.17 [1.03-1.33], 1.22 [1.08-1.38], and 1.13 [1.02-1.25], respectively). In conclusion, nonadherence to OAM therapy is associated with ESRD. Adherence to medication therapy can prevent the progressive loss of renal function and ESRD for patients with diabetes.