We investigated associations between serum levels of bilirubin, an endogenous antioxidant, and gastrointestinal cancer risk. In the UK Biobank, prediagnostic serum levels of total bilirubin were measured in blood samples collected from 440,948 participants. In multivariable-adjusted Cox proportional hazard regression, we estimated hazard ratios (HR) and 95% confidence intervals (CI) for associations between bilirubin levels and gastrointestinal cancer risk (colorectum, esophagus, stomach, mouth, pancreas, and liver). After a median follow-up of 7.1 years (interquartile range: 1.4), 5033 incident gastrointestinal cancer cases were recorded. In multivariable-adjusted models, bilirubin levels were negatively associated with risk of esophageal adenocarcinoma (EAC, HR per 1-SD increment in log-total bilirubin levels 0.72, 95%CI 0.56–0.92, p = 0.01). Weak and less robust negative associations were observed for colorectal cancer (CRC, HR per 1-SD increment in log-total bilirubin levels 0.95, 95%CI 0.88–1.02, p = 0.14). Bilirubin levels were positively associated with risk of hepatocellular carcinoma (HCC, HR per 1-SD increment in log-total bilirubin levels 2.07, 95%CI 1.15–3.73, p = 0.02) and intrahepatic bile duct (IBD) cancer (HR per 1-SD increment 1.67, 95%CI 1.07–2.62, p = 0.03). We found no associations with risks of stomach, oral, and pancreatic cancers. Prediagnostic serum levels of bilirubin were negatively associated with risk of EAC and positively associated with HCC and IBD cancer. Further studies are warranted to replicate our findings for specific GI cancers.