OBJECTIVE: To examine the relation between the type of stress ulcer prophylaxis administered and the risk of postoperative pneumonia in patients undergoing coronary artery bypass grafting. DESIGN: Retrospective cohort study. SETTING: Premier Research Database. PARTICIPANTS: 21,214 patients undergoing coronary artery bypass graft surgery between 2004 and 2010; 9830 (46.3%) started proton pump inhibitors and 11,384 (53.7%) started H2 receptor antagonists in the immediate postoperative period. MAIN OUTCOME MEASURE: Occurrence of postoperative pneumonia, assessed using appropriate diagnostic codes. RESULTS: Overall, 492 (5.0%) of the 9830 patients receiving a proton pump inhibitor and 487 (4.3%) of the 11,384 patients receiving an H2 receptor antagonist developed postoperative pneumonia during the index hospital admission. After propensity score adjustment, an elevated risk of pneumonia associated with treatment with proton pump inhibitors compared with H2 receptor antagonists remained (relative risk 1.19, 95% confidence interval 1.03 to 1.38). In the instrumental variable analysis, use of a proton pump inhibitor (compared with an H2 receptor antagonist) was associated with an increased risk of pneumonia of 8.2 (95% confidence interval 0.5 to 15.9) cases per 1000 patients. CONCLUSIONS: Patients treated with proton pump inhibitors for stress ulcer had a small increase in the risk of postoperative pneumonia compared with patients treated with H2 receptor antagonists; this risk remained after confounding was accounted for using multiple analytic approaches.