Objective. SLE is associated with increased risk of diabetes mellitus. Treatment for SLE requires high-dose glucocorticoids that may worsen glucose homoeostasis. HCQ can reduce diabetes risk in RA. This study aimed to investigate the association of HCQ use and diabetes mellitus risk in SLE patients. Methods. This nationwide, population-based cohort study was conducted using the Taiwan National Health Insurance Research Database. In the period 2001-10, 8628 newly diagnosed SLE patients were identified after excluding those with a previous diagnosis of RA, psoriasis or diabetes mellitus. Incidence of diabetes mellitus was identified as a new diagnostic code using a diabetes mellitus-specific medication. Results. Two hundred and twenty-one newly diagnosed diabetes mellitus patients were identified among SLE patients (6795 had taken HCQ and 1833 had never taken HCQ), with an average follow-up period of 5.6 years. Compared with patients without HCQ treatment, the hazard ratio (HR) of diabetes mellitus in patients taking HCQ at a cumulative dose ≥129 g was reduced [HR 0.26 (95% CI 0.18, 0.37), P < 0.001]. Daily glucocorticoid ≥10 mg prednisolone-equivalent dose was associated with increased risk of developing diabetes mellitus [HR 2.47 (95% CI 1.44, 4.23), P = 0.001], which was minimized by concomitant HCQ use at a cumulative dose ≥129 g. Conclusion. In SLE patients, the use of HCQ is associated with reduced risk of incident diabetes mellitus in a dose-dependent manner. High-dose glucocorticoids increase the risk of diabetes, which can be decreased by concomitant HCQ use.