Although positive associations have been found for diabetes and a number of cancer sites, investigations of stomach cancer are limited and the results lack consistency. In this prospective study we investigated the relationship between type 2 diabetes mellitus (T2DM) and stomach cancer risk in mainland China. We assessed the associations among T2DM, T2DM duration, and stomach cancer risk in two prospective population-based cohorts, the Shanghai Women's Health Study and the Shanghai Men's Health Study. Included in the study were 61 480 men and 74 941 women. Stomach cancer cases were identified through annual record linkage to the Shanghai Cancer Registry, and verified through home visits and review of medical charts. After a median follow-up of 7.5 years for the Shanghai Men's Health Study and 13.2 years for the Shanghai Women's Health Study, a total of 755 incident cases of stomach cancer (376 men and 379 women) were identified through to September 2013. Overall, we did not find any evidence that T2DM was associated with an increased risk of stomach cancer either in men (multi-adjusted hazard ratio = 0.83, 95% confidence interval, 0.59-1.16) or in women (multi-adjusted hazard ratio = 0.92, 95% confidence interval, 0.68-1.25). Our findings from two large prospective population-based cohorts suggest that T2DM was not associated with stomach cancer risk.