N-nitroso compounds (NOC) are potent animal carcinogens and potential human carcinogens. The primary source of exposure for most individuals may be endogenous formation, a process that can be inhibited by dietary polyphenols. To estimate the risk of gastric cancer (GC) in relation to the individual and combined consumption of polyphenols and NOC precursors (nitrate and nitrite), a population-based case-control study was carried out in Mexico City from 2004 to 2005 including 257 histologically confirmed GC cases and 478 controls. Intake of polyphenols, nitrate and nitrite were estimated using a food frequency questionnaire. High intakes of cinnamic acids, secoisolariciresinol and coumestrol were associated with an approximately 50% reduction in GC risk. A high intake of total nitrite as well as nitrate and nitrite from animal sources doubled the GC risk. Odds ratios around 2-fold were observed among individuals with both low intake of cinnamic acids, secoisolariciresinol or coumestrol and high intake of animal-derived nitrate or nitrite, compared to high intake of the polyphenols and low animal nitrate or nitrite intake, respectively. Results were similar for both the intestinal and diffuse types of GC. Our results show, for the first time, a protective effect for GC because of higher intake of cinnamic acids, secoisolariciresinol and coumestrol, and suggest that these polyphenols reduce GC risk through inhibition of endogenous nitrosation. The main sources of these polyphenols were pears, mangos and beans for cinnamic acids; beans, carrots and squash for secoisolariciresinol and legumes for coumestrol.