OBJECTIVES: Gastrointestinal (GI) bleeding may impose a serious threat in patients undergoing total hip or knee replacement (THR/TKR). The objectives of this study are to evaluate the timing of GI bleeding following THR/TKR and to determine the effect modification by proton pump inhibitor (PPI) use. METHODS : In a nationwide Danish cohort study, we selected all patients with a primary THR/TKR between 1998 and 2007 (n = 95,115). Three control subjects without THR/TKR were matched by age, sex, and region. We calculated disease and medication adjusted (adj.) Hazard ratios (HRs) for GI bleeding with THR/TKR vs. controls. PPI use was assessed in the previous 3 months (in a time-dependent manner). RESULTS: We identified a 6-fold increased risk of GI bleeding during the first 2 weeks following THR (adj. HR, 6.02; 95 % confidence interval (CI), 4.06-8.92) and a 2.3-fold increased risk for TKR patients (adj. HR, 2.30; 95 % CI, 1.17-4.54), both vs. matched controls. The elevated risk lasted longer in THR patients (12 weeks) as compared with TKR patients (6 weeks). PPI use lowered the HR for GI bleeding by 74 % during the first 6 weeks following THR, but not TKR. CONCLUSIONS: This study demonstrated an increased risk of GI bleeding during the first 2 weeks following THR (6-fold) and TKR (2.3-fold), and remained increased for up to 6 (TKR) to 12 weeks (THR) after surgery. PPI use substantially lowered this elevated risk in THR patients, but not in TKR patients.