Previous studies have suggested that the use of proton pump inhibitors (PPIs) more than doubles the risk of acute kidney injury (AKI) in cancer patients receiving immune checkpoint inhibitors (ICIs). However, this association may be confounded. Therefore, we conducted a register‐based cohort study to examine the risk of AKI in users and nonusers of PPIs among cancer patients treated with ICIs in Denmark from 2011 through 2021 while accounting for a comprehensive range of potential confounders. PPI use was determined based on redeemed prescriptions of PPIs before ICI initiation. We identified laboratory‐recorded AKI events within the first year after ICI initiation. We estimated the risks and hazard ratios (HRs) of AKI while accounting for a comprehensive range of confounders (including comorbidities and comedication) by propensity score weighting. Furthermore, we performed an additional per‐protocol analysis while accounting for informative censoring by weighting. We identified 10 200 cancer patients including 2749 (27%) users, 6214 (61%) nonusers, and 1237 (12%) former users of PPIs. PPI users had an increased risk of AKI compared to nonusers (1‐year risk, 24.7% vs 19.9%; HR, 1.42 [95% confidence interval (CI), 1.29‐1.56]); however, this association attenuated when accounting for confounders (weighted 1‐year risk, 24.2% vs 23.8%; weighted HR, 1.06 [95% CI, 0.93‐1.21]). In the per‐protocol analysis, the crude HR was 1.86 (95% CI, 1.63‐2.12), while the weighted HR was 1.24 (95% CI, 1.03‐1.49). Thus, the association between PPI use and AKI could largely be explained by confounding, suggesting that previous studies may have overestimated the association.