Background People who use drugs (PWUD) are a key target population to reduce the burden of hepatitis C virus (HCV) infection. Aim To assess risk factors and temporal trends of active HCV infection in PWUD in Madrid, Spain. Methods We conducted a retrospective study between 2017 and 2023, including 2,264 PWUD visiting a mobile screening unit. Data about epidemiology, substance use and sexual risk behaviour were obtained through a 92-item questionnaire. HCV was detected by antibody test, followed by RNA test. The primary outcome variable was active HCV infection prevalence, calculated considering all individuals who underwent RNA testing and analysed by logistic regression adjusted by the main risk factors. Results Of all participants, 685 tested positive for anti-HCV antibodies, and 605 underwent RNA testing; 314 had active HCV infection, and 218 initiated treatment. People who inject drugs (PWID) were identified as the main risk group. The active HCV infection rate showed a significant downward trend between 2017 and 2023 in the entire study population (23.4% to 6.0%), among PWID (41.0% to 15.0%) and PWUD without injecting drug use (7.0% to 1.3%) (p < 0.001 for all). These downward trends were confirmed by adjusted logistic regression for the entire study population (adjusted odds ratio (aOR): 0.78), PWID (aOR: 0.78), and PWUD non-IDU (aOR: 0.78). Conclusions Our study demonstrates a significant reduction in active HCV infection prevalence among PWUD, particularly in PWID, which suggests that efforts in the prevention and treatment of HCV in Madrid, Spain, have had an impact on the control of HCV infection.