Background. Hydroxychloroquine has been shown to inhibit severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2) in vitro, but early clinical studies found no benefit treating patients with coronavirus disease 2019 (COVID-19). We set out to evaluate the effectiveness of hydroxychloroquine for prevention, as opposed to treatment, of COVID-19 mortality. Methods. We pre-specified and conducted an observational, population-based cohort study using national primary care data and linked death registrations in the OpenSAFELY platform, representing 40% of the general population in England. We used Cox regression to estimate the association between ongoing routine hydroxychloroquine use prior to the COVID-19 outbreak in England and risk of COVID-19 mortality among people with rheumatoid arthritis (RA) or systemic lupus erythematosus (SLE). Model adjustment was informed by a directed acyclic graph. Findings. Of 194,637 patients with RA or SLE, 30,569 (15.7%) received ≥2 prescriptions of hydroxychloroquine in the six months prior to 1 March 2020. Between 1 March 2020 and 13 July 2020, there were 547 COVID-19 deaths, 70 among hydroxychloroquine users. Estimated standardised cumulative COVID-19 mortality was 0.23% (95% CI 0.18-0.29) among users and 0.22% (95% CI 0.20-0.25) among non-users; an absolute difference of 0.008% (95% CI -0.051-0.066). After accounting for age, sex, ethnicity, use of other immunuosuppressives, and geographic region, no association with COVID-19 mortality was observed (HR 1.03, 95% CI 0.80-1.33). We found no evidence of interactions with age or other immunosuppressives. Quantitative bias analyses indicated observed associations were robust to missing information regarding additional biologic treatments for rheumatological disease. We observed similar associations with the negative control outcome of non-COVID-19 mortality. Interpretation. We found no evidence of a difference in COVID-19 mortality among patients who received hydroxychloroquine for treatment of rheumatological disease prior to the COVID-19 outbreak in England.