We conducted a large population-based case-control study in Sweden to examine the association of dietary patterns and the development of cancers from the esophagus or gastroesophageal junction. In total 185 patients with esophageal adenocarcinoma, 165 with esophageal squamous-cell carcinoma, 258 with gastric cardia adenocarcinoma, and 815 randomly selected population controls underwent face-to-face interviews. Exploratory factor analysis was used to identify possible dietary patterns. Multivariate logistic regression with adjustments for age, sex, years of education, body mass index, physical activity, symptomatic gastroesophageal reflux, smoking, and total energy intake was used to estimate odds ratios (ORs) and their 95% confidence intervals (CIs). We identified three major dietary patterns in this population, for example, "healthy diet" (high in vegetables, tomato, fruits, fish, and poultry), "Western diet" (high in processed meat, red meat, sweets, high-fat dairy, and high-fat gravy), and "alcohol drinker" (high in intakes of beer, liquor, and French fries). We found that a healthy diet tended to moderately decrease the risk of all three cancers under study, although none of the associations was statistically significant. A high score of Western diet was associated with increased risks of gastric cardia adenocarcinoma (high 3rd tertile vs. low 1st quartile, OR = 1.8, 95% CI = 1.1-2.9, P for trend = 0.04) and esophageal adenocarcinoma (high 3rd tertile vs. low 1st tertile, OR = 1.6, 95% CI = 0.9-3.1, P for trend = 0.13), whereas a dietary pattern characterized by high beer and liquor intake (alcohol drinker) significantly increased the risk of squamous-cell carcinoma of the esophagus (3rd tertile vs. low 1st tertile, OR = 3.5, 95% CI = 1.9-6.3, P for trend < 0.0001). Our study confirms the important role of diet in the carcinogenesis of esophageal and cardia cancer.