It remains controversial whether entecavir (ETV) and tenofovir disoproxil fumarate (TDF) is associated with different clinical outcomes for chronic hepatitis B (CHB). This study aimed to compare the long-term risk of ETV versus TDF on hepatocellular carcinoma (HCC) and intrahepatic cholangiocarcinoma (ICC) in CHB patients from a large multi-institutional database in Taiwan. From 2011 to 2018, a total of 21,222 CHB patients receiving ETV or TDF were screened for eligibility. Patients with coinfection, preexisting cancer and less than 6 months of follow-up were excluded. Finally, 7248 patients (5348 and 1900 in the ETV and TDF groups, respectively) were linked to the National Cancer Registry database for the development of HCC or ICC. Propensity score matching (PSM) (2:1) analysis was used to adjust for baseline differences. The HCC incidence between two groups was not different in the entire population (hazard ratio [HR] 0.82; 95% confidence interval [CI] 0.66–1.02, p = 0.078) and in the PSM population (HR 0.83; 95% CI 0.65–1.06, p = 0.129). Among decompensated cirrhotic patients, a lower risk of HCC was observed in TDF group than in ETV group (HR 0.54; 95% CI 0.30–0.98, p = 0.043, PSM model). There were no differences between ETV and TDF groups in the ICC incidence (HR 1.84; 95% CI 0.54–6.29, p = 0.330 in the entire population and HR 1.04; 95% CI 0.31–3.52, p = 0.954 in the PSM population, respectively). In conclusion, treatment with ETV and TDF showed a comparable long-term risk of HCC and ICC in CHB patients.