This study aimed to assess risk factors for developing marginal ulcer (MU) after gastric bypass (GBP) surgery for obesity.MU is a common and potentially serious complication of GBP surgery, little is known about its etiology.This population-based cohort study of GBP in 2006-2011 evaluated MU in relation to diabetes, hyperlipidemia, hypertension, chronic obstructive pulmonary disease (COPD), ulcer history, use of proton pump inhibitors (PPIs), aspirin, nonsteroidal anti-inflammatory drugs (NSAIDs), and selective serotonin reuptake inhibitors (SSRIs). Multivariable Cox proportional hazard regression models estimated hazard ratios (HRs) and 95% confidence intervals (CIs), adjusted for confounding.Among 20,294 GBP patients, diabetes and peptic ulcer history entailed statistically significantly increased risk of MU (HR = 1.26, 95% CI 1.03-1.55 and HR = 2.70, 95% CI 1.81-4.03), although hyperlipidemia, hypertension, and COPD did not. PPI users had an increased HR of MU (HR = 1.37, 95% CI 1.17-1.60). Aspirin and NSAID consumption less than or equal to median entailed decreased HRs of MU (HR = 0.56, 95% CI 0.37-0.86 and HR = 0.30, 95% CI 0.24-0.38), although aspirin and NSAID users more than median had an increased risk and no association with MU, respectively (HR = 1.90, 95% CI 1.41-2.58 and HR = 0.90, 95% CI 0.76-1.87). The use of SSRI less than or equal to median had a decreased risk of MU (HR = 0.50, 95% CI 0.37-0.67), although use more than median entailed increased HR (HR = 1.26, 95% CI 1.01-1.56).Diabetes and peptic ulcer history seem to be risk factors for MU, but not hyperlipidemia, hypertension, or COPD. Limited doses of aspirin, NSAIDs, and SSRIs might not increase the risk, although higher doses of aspirin do. The association with PPI could be due to confounding by indication.