Immune checkpoint inhibitors such as anti-PD-1 antibodies (aPD1) can be effective in treating advanced cancers. However, many patients do not respond and the mechanisms underlying these differences remain incompletely understood. In this study, we profile a cohort of patients with locally-advanced or metastatic basal cell carcinoma undergoing aPD-1 therapy using single-cell RNA sequencing, high-definition spatial transcriptomics in tumors and draining lymph nodes, and spatial immunoreceptor profiling, with long-term clinical follow-up. We find that successful responses to PD-1 inhibition are characterized by an induction of B-cell receptor (BCR) clonal diversity after treatment initiation. These induced BCR clones spatially co-localize with T-cell clones, facilitate their activation, and traffic alongside them between tumor and draining lymph nodes to enhance tumor clearance. Furthermore, we validated aPD1-induced BCR diversity as a predictor of clinical response in a larger cohort of glioblastoma, melanoma, and head and neck squamous cell carcinoma patients, suggesting that this is a generalizable predictor of treatment response across many types of cancers. We discover that pre-treatment tumors harbor a characteristic gene expression signature that portends a higher probability of inducing BCR clonal diversity after aPD-1 therapy, and we develop a machine learning model that predicts PD-1-induced BCR clonal diversity from baseline tumor RNA sequencing. These findings underscore a dynamic role of B cell diversity during immunotherapy, highlighting its importance as a prognostic marker and a potential target for intervention in non-responders.