IntroductionWe aimed to assess sex differences in treatment outcomes and adherence comparing men who have sex with women (MSW), men who have sex with men (MSM), and women who have sex with men (WSM), as well as men and women who inject drugs living with HIV on combination antiretroviral therapy (ART) in Guangdong, China. MethodsWe performed a retrospective observational cohort study with data from the National Free Antiretroviral Treatment Program database. We included ART-naive patients aged 18 to 80 years who had contracted HIV through sex or injecting drugs, initiated first-line ART between January 2004 and December 2016, and had at least 60 days of follow-up. Participants were followed for five years. Kaplan-Meier analysis and Cox proportional hazard models were used to evaluate all-cause mortality. Cumulative incidence function and Cox proportional hazards models accounting for competing risks were used to evaluate disease progression to AIDS. Modified Poisson regression models were used to evaluate immunological and virological responses and loss to follow-up. Repeated measures analysis was used to evaluate regular CD4+ cell count, HIV viral load monitoring, ART adherence, side effects, and interruption of ART. FindingsWe included 26,409 persons living with HIV. 21,779 (82·5%) people acquired HIV through sex (5118 WSM [23·5%], 8506 MSW [39·0%], 8175 MSM [37·5%]), and 4610 people (17·5%) through injection drug use (249 women [5·4%], 4361 men [94·6%]). Among those infected through sex, MSW had increased risks of all-cause mortality (adjusted hazard ratio [aHR] 1·48, 95% CI 1·20–1·83), progression to AIDS (1·27, 1·09–1·47), virological failure (adjusted incidence rates ratio [aIRR] 1·27, 95% CI 1·09–1·48), and loss to follow-up (1·22, 1·10–1·35) compared to WSM. In contrast, MSM had lower risk of all-cause mortality (aHR 0·49, 95%CI 0·32–0·76), disease progression to AIDS (0·83, 0·68–1·00), and virological failure (aIRR 0·78, 95%CI 0·65–0·94), were more likely to receive regular CD4+ cell count (1·08, 1·07–1·10) and HIV viral load monitoring (1·13, 1·12–1·15), were less likely to report missing ART doses (0·54, 0·49–0·61), interrupt ART (0·34, 0·26–0·44), or be lost to follow-up (0·56, 0·49–0·65) compared to WSM. Men who inject drugs were almost twice as likely as women who inject drugs to die (aHR 1·72, 95%CI 1·03–2·85), experience disease progression to AIDS (2·05, 1·18–3·57), virological failure (aIRR 1·81, 95%CI 1·19–2·76), report ART side effects (1·78, 1·43–2·22), and interruptions in ART (2·29, 1·50–3·50). InterpretationOur findings highlight the importance of identifying potentially at-risk MSW and promoting HIV education and testing among them. Particular attention is warranted among men who inject drugs to improve timely HIV diagnosis, drug interaction management, and retention in treatment. Additional research from rural settings is needed to assess the long-term treatment outcomes and adherence in MSM with HIV.