Diabetes is involved in the development of several cancers. However, whether type 2 diabetes mellitus (T2DM) as well as other potential risk factors are related to gastric cancer (GC) remains unclear. In this study, 1320 patients with gastric cancer (gastric cancer group) and 1252 thyroid nodule patients (control group), who were admitted in our hospital from Jan 2010 to Dec 2012, were analyzed in a case-control study. Logistic regression analysis was applied to evaluate the risk of diabetes condition, gender, age, body-mass index (BMI) level and other factors for GC. There were 416 patients with DM in the gastric cancer group (31.5%) and 120 patients with DM in the control group (9.6%). The differences between the two groups were significant (P = 0.000). Compared with the control group, the logistic regression analyses suggested that male patients had a higher risk of GC. Moreover, older individuals (especially over 65 years) were more susceptible to GC, and as for T2DM, it was found to be associated with GC, that is, the incidence in the gastric cancer group was significantly higher than in the control group. The OR values of age, T2DM, gender and BMI were 16.951, 15.130, 2.658 and 0.224, respectively. In conclusion, age, gender and T2DM are the risk factors of gastric cancer. Furthermore, male patient over 65 years with T2DM is susceptible to GC, and T2DM is the risk factor only second to age, and there might be synergistic effects among these factors.