SET binding protein 1 (SETBP1) plays crucial roles in various biological processes; however, its involvement in cancer immune checkpoint inhibitor (ICI) treatments has never been studied. In this study, we collected a total of 631 melanoma and 109 non-small cell lung cancer (NSCLC) samples treated with ICI agents (i.e., anti-CTLA-4, anti-PD-1/PD-L1, or combination therapy). Additionally, we obtained their corresponding somatic mutational profiles. We observed that SETBP1 mutated (SETBP1-MUT) melanoma patients exhibited significantly prolonged ICI survival outcomes compared to wild-type patients (HR: 0.56, 95% CI: 0.38-0.81, P = 0.002). Consistently, an elevated ICI response rate was also noticed in the SETBP1-MUT group (42.9% vs. 29.1%, P = 0.016). The Association of SETBP1 mutations with favorable immunotherapeutic prognosis and response was further supported by an independent NSCLC cohort (both P < 0.05). Additional immunological analyses revealed that favorable immune infiltration, tumor immunogenicity, and immune response circuits were enriched in SETBP1-MUT patients. Overall, our findings suggest that SETBP1 mutations may serve as a new biomarker for stratifying beneficiaries of ICI treatments in melanoma and NSCLC, which provides possible evidence for tailoring clinical immunotherapeutic strategies.