Biliary tract cancers, which encompass tumors of the gallbladder, extrahepatic ducts, and ampulla of Vater, are relatively rare tumors with a high fatality rate. Other than a close link with gallstones, the etiology of biliary tract cancers is poorly understood. We conducted a population-based case-control study in Shanghai, China, to examine whether genetic variants in several DNA repair genes are associated with biliary tract cancers or biliary stones. Genomic DNA from 410 patients with biliary tract cancers (236 gallbladder, 127 bile duct, and 47 ampulla of Vater), 891 patients with biliary stones, and 786 healthy subjects randomly selected from the Shanghai population were genotyped for putative functional single nucleotide polymorphisms in four DNA repair genes (MGMT, RAD23B, CCNH, and XRCC3). Of the five single nucleotide polymorphisms examined, only one (MGMT EX5-25C>T, rs12917) was associated with biliary tract cancer. Independent of gallstones, subjects carrying the CT genotype of the MGMT EX5-25C>T marker had a significantly reduced risk of gallbladder cancer [odds ratio (OR), 0.63; 95% confidence interval (95% CI), 0.41-0.97; P = 0.02] and nonsignificant reduced risks of bile duct (OR, 0.61; 95% CI, 0.35-1.06) and ampulla of Vater (OR, 0.85; 95% CI, 0.39-1.87) cancers. However, this marker was not associated with biliary stones, and the other markers examined were not significantly associated with either biliary tract cancers or stones. Findings from this population-based study in Shanghai suggest that MGMT gene variants may alter susceptibility to biliary tract cancer, particularly gallbladder cancer. Confirmation in future studies, however, is required.