Whether tenofovir or entecavir has different effects on the prevention of hepatitis B virus (HBV)-related hepatocellular carcinoma (HCC) in secondary and tertiary preventive settings is still a matter of debate. This study aimed to compare the long-term prognosis of HCC between tenofovir and entecavir in patients with chronic hepatitis B. Chronic hepatitis B patients diagnosed with HCC between November 2008 and December 2018 and treated with either entecavir or tenofovir at a tertiary center in Korea were included. The effect of tenofovir compared with entecavir on the prognosis of HBV-related HCC was assessed using multivariable-adjusted Cox and propensity score (PS)-matched analyses. Various predefined subgroup analyses were conducted. During a median follow-up period of 3.0 years, the mortality rate for entecavir-treated patients (n= 3469) was 41.2%, while tenofovir-treated patients (n= 3056) had a mortality rate of 34.6%. Overall survival (OS) was better in the tenofovir group (adjusted hazard ratio [aHR], 0.79; P < .001), which were consistently observed in the PS-matched analysis. The magnitude of the risk difference in OS was more prominent 2 years after the diagnosis of HCC (aHR, 0.50; P < .001) than 2 years before (aHR, 0.88; P= .005), and it was more pronounced in patients with earlier HCC stages. In all subgroups, except for those with shorter life expectancy, such as those with compromised liver function, tenofovir was associated with better OS compared with entecavir. Among patients with HBV-related HCC, those treated with tenofovir had a better prognosis than those treated with entecavir, particularly among those with prolonged survival.