BACKGROUND: Evidence on associations between self-reported diabetes mellitus, diabetes duration, age at diabetes diagnosis, insulin treatment, and risk of biliary tract cancer (BTC) and hepatocellular carcinoma (HCC), independent of general and abdominal obesity is scarce. PATIENTS AND METHODS: We conducted a prospective analysis in the EPIC-cohort study among 363 426 participants with self-reported diabetes data. Multivariable adjusted relative risks and 95% confidence intervals were estimated from Cox regression models. In a nested case-control subset, analyses were carried out in HCV/HBV-negative individuals. RESULTS: During 8.5 years of follow-up, 204 BTC cases [including 75 gallbladder cancer (GBC) cases], and 176 HCC cases were identified. Independent of body mass index and waist-to-height ratio diabetes status was associated with higher risk of BTC and HCC [1.77 (1.00-3.13) and 2.17 (1.36-3.47)]. For BTC, the risk seemed to be higher in participants with shorter diabetes duration and those not treated with insulin. Regarding cancer subsites, diabetes was only associated with GBC [2.72 (1.17-6.31)]. The risk for HCC was particularly higher in participants treated with insulin. The results were not appreciably different in HCV/HBV-negative individuals. CONCLUSION(S): This study supports the hypothesis that diabetes is a risk factor for BTC (particularly GBC) and HCC. Further research is required to establish whether diabetes treatment or duration is associated with these cancers.