Emerging data suggest that chronic hepatitis B virus (HBV) and hepatitis C virus (HCV) infections may also play a role in extrahepatic bile duct cancers. To test the HBV hypothesis, we examined the relationship of HBV/HCV infection with risks of biliary tract cancer and biliary stones in a population-based case-control study conducted in Shanghai, China. Standard assays were used to detect HBV surface antigen (HBsAg) and antibodies against HBV core antigen (anti-HBc) and hepatitis C virus (anti-HCV) in sera from 417 patients with biliary tract cancers, 517 with biliary stones, and 762 healthy controls randomly selected from the population. Unconditional logistic regression was used to calculate the odds ratios (ORs) and 95% confidence intervals (CIs) for each disease type. HBsAg seroprevalence was 7.3% among population controls and 14.2% among patients with extrahepatic bile duct cancer, resulting in a 2.4-fold risk of extrahepatic bile duct cancer (95% CI 1.2-4.5). No association was found for cancers of the gallbladder (prevalence 8.2%) or the ampulla of Vater (6.1%), or for stones in the gallbladder (10.1%) or bile duct (9.3%). Further adjustment for education, smoking, body mass index, diabetes and gallstones did not materially change the results. Prevalence of HCV infection in this population was low (2%), limiting our ability to detect an association with biliary diseases. In Shanghai, an HBV endemic area, chronic HBV infection was associated with a 2.4-fold risk of extrahepatic bile duct cancer. These results should be confirmed in other populations with varying risks of HBV and HCV infection. © 2007 Wiley-Liss, Inc.