There is still some controversy over a potentially increased short-term risk of developing hepatocellular carcinoma (HCC) after the initiation of direct-acting antiviral (DAA) therapy, even though a decreased long-term risk of HCC has been reported following a sustained virological response in patients with chronic hepatitis C virus (HCV) infection. We characterized the time-varying effect of DAAs on the risk of the occurrence of HCC in patients with cirrhosis and HCV infection. We analysed patients with cirrhosis and chronic HCV infection from the ANRS CO22 HEPATHER cohort study. We excluded patients with active HBV coinfection, liver transplantation or a past history of HCC. We used a flexible weighted effect cumulative exposure Cox model to characterize the time-varying effect of DAAs on the risk of HCC. A total of 3595 patients, mean age 59.3 years old, 65% men, were eligible for the study. Median follow-up was 36.8 months (IQR 24.6-47.1). DAAs were started during follow-up in 3292 patients. Three hundred and fifty-six HCCs were reported (275 treated, 81 untreated). Overall, a constant decrease in the risk of occurrence of HCC (vs untreated) was found from the start of treatment. Results were similar in patients without a history of decompensated cirrhosis (DC). Analysis of patients with a past history of DC showed a nonsignificant increase in the occurrence of HCC over the first 6 months, while the HR was significantly decreased at 14 months. These findings support the urgent initiation of DAAs in all patients. © 2019 John Wiley & Sons Ltd.