We prospectively examined the relation between pretrial serum vitamin D status and risk of oesophageal and gastric cancers among subjects who developed cancer over 5.25 years of follow-up, including 545 oesophageal squamous cell carcinomas (ESCC), 353 gastric cardia adenocarcinomas, 81 gastric noncardia adenocarcinomas, and an age- and sex-stratified random sample of 1105 subjects. The distribution of serum 25(OH)D was calculated using the known sampling weights. For the cohort as a whole, the 25th, 50th, and 75th percentile concentrations of 25(OH)-vitamin D were 19.6, 31.9, and 48.7 nmol l(-1), respectively, and we found that higher serum 25(OH)D concentrations were associated with monotonically increasing risk of ESCC in men, but not in women. Comparing men in the fourth quartile of serum 25(OH)D concentrations to those in the first, we found a hazard ratio (HR) (95% confidence interval (CI)) of 1.77 (1.16-2.70), P trend=0.0033. The same comparison in women had a HR (95% CI) of 1.06 (0.71-1.59), P trend=0.70. We found no associations for gastric cardia or noncardia adenocarcinoma. Among subjects with low vitamin D status, higher serum 25(OH)D concentrations were associated with significantly increased risk of ESCC in men, but not in women. Further refinements of the analysis did not suggest any factors, which could explain this unexpected result.