IMPORTANCE Histamine-2 receptor antagonists (H2RAs) and proton pump inhibitors (PPIs) are commonly used to prevent gastrointestinal tract (GI) hemorrhage in critically ill patients. The stronger acid suppression of PPIs may reduce the rate of bleeding but enhance infectious complications, specifically pneumonia and Clostridium difficile infection (CDI). OBJECTIVE To evaluate the occurrence and risk factors for GI hemorrhage, pneumonia, and CDI in critically ill patients. DESIGN, SETTING, AND PARTICIPANTS A pharmacoepidemiological cohort study was conducted of adult patients requiring mechanical ventilation for 24 hours or more and administered either an H2RA or PPI for 48 hours or more while intubated across 71 hospitals between January 1, 2003, and December 31, 2008. Propensity score-adjusted and propensity-matched multivariate regression models were used to control for confounders. MAIN OUTCOMES AND MEASURES Primary outcomes were secondary diagnoses of International Classification of Diseases, Ninth Revision (ICD-9)-coded GI hemorrhage, pneumonia, and CDI occurring 48 hours or more after initiating invasive ventilation. RESULTS Of 35 312 patients, 13 439 (38.1%) received H2RAs and 21 873 (61.9%) received PPIs. Gastrointestinal hemorrhage (2.1% vs 5.9%; P < .001), pneumonia (27% vs 38.6%; P < .001), and CDI (2.2% vs 3.8%; P < .001) occurred less frequently in the H2RA group. After adjusting for propensity score and covariates, odds ratios of GI hemorrhage (2.24; 95% CI, 1.81-2.76), pneumonia (1.2; 95% CI, 1.03-1.41), and CDI (1.29; 95% CI, 1.04-1.64) were greater with PPIs. Similar results were obtained in the propensity-matched models of 8799 patients in each cohort. CONCLUSIONS AND RELEVANCE Proton pump inhibitors are associated with greater risks of GI hemorrhage, pneumonia, and CDI than H2RAs in mechanically ventilated patients. Numerous other risk factors are apparent. These data warrant confirmation in comparative prospective studies.