The observational study involving more than 1,300 people was led by the London School of Hygiene & Tropical Medicine (LSHTM), University of Malawi College of Medicine and colleagues at the University of Cambridge.
It found most patients admitted to hospital knew their HIV status, and that 90% were taking antiretroviral therapy.
However, approximately one-third of patients established on HIV treatment had significant levels of HIV in their blood, and more than 80% of these patients had resistance to two or more of their HIV antiretroviral drugs.
Patients with multidrug resistant HIV were 70% more likely to die within two months of being admitted to hospital than those without drug resistance.
This is the first study reporting such data in hospitalised patients, as access to HIV drug resistance testing is not widely available in high HIV burden African settings.
Dr Ankur Gupta-Wright from LSHTM and project lead said: "There has been an unprecedented scale-up of antiretroviral therapy in high-HIV prevalence settings in sub-Saharan Africa. However, HIV remains a common cause of admission to hospital, with a high risk of death. Our results show drug resistance is an important cause."
Distinguishing HIV drug resistance from alternative explanations for progressive illness whilst taking antiretroviral (HIV) treatment, such as patients not sticking to required dosage or stopping treatment altogether, is not usually possible. Patients who develop advanced HIV while established on ART often go undetected.
Most available data on HIV drug resistance come from outpatient clinics, where failing HIV treatment is much less common. However, hospitalised patients represent a key target group for intensified interventions, given their relatively high risks of treatment failure, advanced immunosuppression, and high short-term mortality.
This study was based on patients living with HIV who were admitted to hospital in Zomba, southern Malawi. Samples were collected at the time of hospital admission to test for the amount of HIV virus in the blood, to see if patients were responding to their HIV antiretroviral medication.
By sequencing the virus and looking for mutations, patients with high levels of HIV in their blood were tested for resistance to HIV drugs. After two months, the team compared whether patients failing ART and/or with HIV drug resistance were more likely to die.
Of 237 patients with HIV drug resistance results available, 195 (82%) had resistance to lamivudine, 128 (54%) to tenofovir, and 219 (92%) to efavirenz (all first-line drugs used to treat HIV at the time of the study).
Dr Gupta-Wright said: "These are worrying results. ART changes and saves lives, but drug resistance is threatening this progress. Timely diagnosis and management of ART failure and drug resistance in this patient population could improve individual patient outcomes and contribute to the UNAIDS 95-95-95 targets set for 2030. Rapid HIV-1 viral load tests for hospital inpatients need to be implemented, so results are available quickly and patients can be switched to alterative antiretroviral therapy.
"This could potentially save the lives of many patients living with HIV on treatment who are admitted to hospital."
Professor Ravi Gupta, from Cambridge University and senior author on the study said: ''These important findings highlight the threat posed by drug resistant HIV and call for rapid tests for drug resistant virus that could aid in determining treatments and interventions for patients in hospital.''
The authors acknowledge limitations of this study including the introduction of a new antiretroviral drug in Malawi last year called Dolutegravir, which may overcome some of the resistance found in this study.
The study was funded by the Joint Global Health Trials Scheme of the Medical Research Council, UK Department for International Development, and Wellcome Trust.