Enhancing mental health-related quality of life (MHRQOL) is an important clinical objective for people with HIV (PWH), due to their elevated risk of psychological distress and mental health challenges. Depression, pain, stigma, and discrimination are among the main contributors to poor MHRQOL in this population and can negatively impact PWH's interaction with their healthcare providers, and vice versa. We used structural equation modeling to examine whether the quality of patient-provider engagement in HIV primary care mediated the effects of depression and prior experiences of discrimination in healthcare settings on later MHRQOL, assessed using the SF- 12 Mental Component Summary (MCS- 12), among a sample of predominately African Americans with HIV and a history of drug use. A total of 331 participants, recruited from HIV clinics and community venues in Baltimore, Maryland, USA, completed three semi-annual surveys between 2014 and 2018. At baseline, the sample showed a high percentage of probable depression (35.6%) and a low MCS- 12 mean score (38.72, SD = 6.88) compared with the US general population norm of 50 (SD = 10). There were significant indirect paths from baseline depression (beta = - 0.04, 95% CI = - 0.10, - 0.01) and healthcare discrimination (beta = - 0.05, 95% CI = - 0.12, - 0.01) to lower MHRQOL at 12-months, mediated through reduced patient-centered patient-provider engagement with primary care providers at 6-months, after adjusting for baseline assessment of the mediator and the outcome, demographic covariates, substance use, pain level, and time since HIV diagnosis. Findings suggest a potential for mitigating the impacts of depression and healthcare discrimination on MHRQOL through intervening on the quality of patient-provider engagement.