Background: It is unclear whether HIV infection is associated with risk of COVID-19 death. We aimed to investigate this in a large-scale population-based study in England. Methods: Working on behalf of NHS England, we used the OpenSAFELY platform to analyse routinely collected electronic primary care data linked to national death registrations. People with a primary care record for HIV infection were compared to people without HIV. COVID-19 death was defined by ICD-10 codes U07.1 or U07.2 anywhere on the death certificate. Cox regression models were used to estimate the association between HIV infection and COVID-19 death, initially adjusted for age and sex, then adding adjustment for index of multiple deprivation and ethnicity, and finally for a broad range of comorbidities. Interaction terms were added to assess effect modification by age, sex, ethnicity, comorbidities and calendar time. Results: 17.3 million adults were included, of whom 27,480 (0.16%) had HIV recorded. People living with HIV were more likely to be male, of black ethnicity, and from a more deprived geographical area than the general population. There were 14,882 COVID-19 deaths during the study period, with 25 among people with HIV. People living with HIV had nearly three-fold higher risk of COVID-19 death than those without HIV after adjusting for age and sex (HR=2.90, 95% CI 1.96-4.30). The association was attenuated but risk remained substantially raised, after adjustment for deprivation and ethnicity (adjusted HR=2.52, 1.70-3.73) and further adjustment for comorbidities (HR=2.30, 1.55-3.41). There was some evidence that the association was larger among people of black ethnicity (HR = 3.80, 2.15-6.74, compared to 1.64, 0.92-2.90 in non-black individuals, p-interaction=0.045) Interpretation: HIV infection was associated with a markedly raised risk of COVID-19 death in a country with high levels of antiretroviral therapy coverage and viral suppression; the association was larger in people of black ethnicity.