Whole grains are known to influence postprandial glucose response and insulin demand and are inversely associated with diabetes risk. Genetic variation of the transcription factor-7-like 2 encoding gene (TCF7L2) is assumed to promote an early insulin secretory defect and has been consistently attributed to the risk of developing type 2 diabetes. The present study examined the hypothesis that the protective effect of whole grains might be attenuated in the presence of the rs7903146 risk-conferring T-allele. We employed a case–cohort study of 2318 randomised individuals and 724 incident type 2 diabetes cases from the European Prospective Investigation into Cancer and Nutrition (EPIC)-Potsdam cohort. Multivariate Cox regression was used to estimate relative risks of diabetes including product terms testing for the genotype-specific effect modification of dietary whole grain. Dietary intake of whole grains was assessed by a validated FFQ. The TCF7L2 rs7903146 T-allele was associated with type 2 diabetes (hazard ratio = 1·51; 95 % CI 1·21, 1·87) and modified the inverse association between whole-grain intake and diabetes risk (P = 0·016 for interaction). While whole-grain intake was inversely associated with diabetes risk among rs7903146 CC homozygote carriers (hazard ratio for 50 g portion per d = 0·86; 95 % CI 0·75, 0·99), the T-allele negated the protective effect of whole-grain intake (hazard ratio among T-allele carriers for 50 g portion per d = 1·08; 95 % CI 0·96, 1·23). These data provide evidence that the beneficial effect of whole-grain intake on diabetes risk is modified by TCF7L2 rs7903146.