Biliary tract cancers, encompassing gallbladder, extrahepatic bile duct and ampulla of Vater cancers, are uncommon but often fatal malignancies. Hormone-related factors, including parity, oral contraceptive use, obesity, and gallstones, have been implicated in the etiology of these cancers. To further clarify the role of hormones in biliary tract cancers and biliary stones, we genotyped 18 single-nucleotide polymorphisms (SNPs) in nine genes involved in steroid hormone biosynthesis, metabolism and transport in a population-based case-control study in Shanghai, China. This study included subjects who completed an interview and provided blood, which totaled 411 biliary tract cancer and 893 biliary stone patients and 786 healthy Shanghai residents. The CYP1A1 IVS1 + 606 (rs2606345) T allele was associated with gallbladder [odds ratio (OR) = 2.0, 95% confidence interval (CI), 1.3-3.0] and bile duct cancers (OR = 1.8, 95% CI = 1.1-3.1), whereas the CYP1A1 Ex7 + 131 (rs1048943) G allele was associated with ampulla of Vater cancer (OR = 2.9, 95% CI = 1.5-5.4). After taking into account multiple comparisons for SNPs within each gene, CYP1A1 was significantly associated with gallbladder (P = 0.004) and ampulla of Vater cancers (P = 0.01), but borderline with bile duct cancer (P = 0.06). The effect of CYP1A1 IVS1 + 606 on gallbladder cancer was more pronounced among non-obese (body mass index < 23) (OR = 3.3, 95% CI = 1.8-6.1; P interaction = 0.001). Among women taking oral contraceptives, the effect of SHBG Ex8 + 6 (rs6259) on gallbladder cancer (OR = 6.7, 95% CI = 2.2-20.5; P interaction = 0.001) and stones (OR = 2.3, 95% CI = 1.1-4.9; P-interaction = 0.05) was statistically significant. Our findings suggest that common variants in hormone-related genes contribute to the risk of biliary tract cancers and stones, possibly by modulating hormone metabolism.