Background In the last three decades, much effort has been invested in measuring and improving the quality of diabetes care. We assessed the association between adherence to diabetes quality indicators and all-cause mortality in the primary care setting. Methods A nationwide, population-based, historical cohort study of all people aged 45–80 with pharmacologically-treated diabetes in 2005 (n = 222,235). Data on annual performance of quality indicators (including indicators for metabolic risk factor management and glycemic control) and vital status were retrieved from electronic medical records of the four Israeli health maintenance organizations. Cox proportional hazards and time-dependent models were used to estimate hazard ratios (HRs) for mortality by degree of adherence to quality indicators. Results During 2,000,052 person-years of follow-up, 35.8% of participants died. An inverse dose–response association between the degree of adherence and mortality was shown for most of the quality indicators. Participants who were not tested for proteinuria or did not visit an ophthalmologist during the first-5-years of follow-up had HRs of 2.60 (95%CI:2.49–2.69) and 2.09 (95%CI:2.01–2.16), respectively, compared with those who were fully adherent. In time-dependent analyses, not measuring LDL-cholesterol, blood pressure, HbA1c, or HbA1c>9% were similarly associated with mortality (HRs ≈1.5). The association of uncontrolled blood pressure with mortality was modified by age, with increased mortality shown for those with controlled blood pressure at older ages (≥65 years). Conclusions Longitudinal adherence to diabetes quality indicators is associated with reduced all-cause mortality. Primary care professionals need to be supported by health care systems to perform quality indicators.