ObjectivesTo assess the outcome of patients hospitalized with COVID‐19 by HIV status and risk factors for severe COVID‐19 in people living with HIV (PWH), we performed a nationwide cohort study using register data.MethodsAll people aged ≥18 years hospitalized with a primary COVID‐19 diagnosis (U07.1 or U07.2) in Sweden between February 2020 and October 2021 were included. The primary outcome was severe COVID‐19 [intensive care unit (ICU) admission or 90‐day mortality]. Secondary outcomes were days in hospital and ICU, complications in hospital, and risk factors for severe COVID‐19 in PWH. Regression analyses were performed to assess severe COVID‐19 by HIV status and risk factors.ResultsData from 64 815 hospitalized patients were collected, of whom 121 were PWH (0.18%). PWH were younger (p < 0.001), and larger proportions were men (p = 0.014) and migrants (p < 0.001). Almost all PWH had undetectable HIV‐RNA (93%) and high CD4 T‐cell counts (median = 560 cells/μL, interquartile range: 376–780). In an unadjusted model, PWH had statistically significant lower odds of severe COVID‐19 compared with patients without HIV [odds ratio (OR) = 0.6, 95% confidence interval (CI): 0.34–0.94], but there was no significant difference after adjusting for age and comorbidity (adjusted OR = 0.7, 95% CI: 0.43–1.26). A statistically significant lower proportion of PWH (8%, 95% CI: 5–15%) died within 90 days compared with those without HIV (16%, 95% CI: 15–16%, p = 0.024). There was no statistically significant difference in days in hospital and complications during the hospital stay between PWH and patients without HIV.ConclusionsIn this nationwide study including well‐treated PWH, HIV was not a risk factor in hospitalized patients for developing severe COVID‐19.