Treatment with immune checkpoint blockade (ICB) frequently triggers immune-related adverse events (irAEs), causing considerable morbidity. In 214 patients receiving ICB for melanoma, we observed increased severe irAE risk in minor allele carriers of rs16906115, intronic to IL7. We found that rs16906115 forms a B cell-specific expression quantitative trait locus (eQTL) to IL7 in patients. Patients carrying the risk allele demonstrate increased pre-treatment B cell IL7 expression, which independently associates with irAE risk, divergent immunoglobulin expression and more B cell receptor mutations. Consistent with the role of IL-7 in T cell development, risk allele carriers have distinct ICB-induced CD8+ T cell subset responses, skewing of T cell clonality and greater proportional repertoire occupancy by large clones. Finally, analysis of TCGA data suggests that risk allele carriers independently have improved melanoma survival. These observations highlight key roles for B cells and IL-7 in both ICB response and toxicity and clinical outcomes in melanoma.