Objective: To examine the hypothesis that risk of oesophageal, but not of gastric or colorectal, cancer is increased in users of oral bisphosphonates. Design: Nested case-control analysis within a primary care cohort of about 6 million people in the UK, with prospectively recorded information on prescribing of bisphosphonates. Setting: UK General Practice Research Database cohort. Participants: Men and women aged 40 years or over - 2954 with oesophageal cancer, 2018 with gastric cancer, and 10 641 with colorectal cancer, diagnosed in 1995-2005; five controls per case matched for age, sex, general practice, and observation time. Main outcome measures: Relative risks for incident invasive cancers of the oesophagus, stomach, and colorectum, adjusted for smoking, alcohol, and body mass index. Results: The incidence of oesophageal cancer was increased in people with one or more previous prescriptions for oral bisphosphonates compared with those with no such prescriptions (relative risk 1.30, 95% confidence interval 1.02 to1.66; P=0.02). Risk of oesophageal cancer was significantly higher for 10 or more prescriptions (1.93, 1.37 to 2.70) than for one to nine prescriptions (0.93, 0.66 to 1.31) (P for heterogeneity=0.002), and for use for over 3 years (on average, about 5 years: relative risk v no prescription, 2.24, 1.47 to 3.43). Risk of oesophageal cancer did not differ significantly by bisphosphonate type, and risk in those with 10 or more bisphosphonate prescriptions did not vary by age, sex, smoking, alcohol intake, or body mass index; by diagnosis of osteoporosis, fracture, or upper gastrointestinal disease; or by prescription of acid suppressants, non-steroidal anti-inflammatory drugs, or corticosteroids. Cancers of the stomach and colorectum were not associated with prescription of bisphosphonate: relative risks for one or more versus no prescriptions were 0.87 (0.64 to 1.19) and 0.87 (0.77 to 1.00). The specificity of the association for oesophageal cancer argues against methodological problems in the selection of cases and controls or in the analysis. Conclusions: The risk of oesophageal cancer increased with 10 or more prescriptions for oral bisphosphonates and with prescriptions over about a five year period. In Europe and North America, the incidence of oesophageal cancer at age 60-79 is typically 1 per 1000 population over five years, and this is estimated to increase to about 2 per 1000 with five years' use of oral bisphosphonates.