ObjectivePain is a prevalent discomfort symptom associated with cancer, yet the correlations and potential mechanisms between pain and the efficacy of cancer immunotherapy remain uncertain.MethodsNon-small cell lung cancer (NSCLC) patients who received immune checkpoint inhibitors (ICIs) in the inpatient department of Guangdong Provincial Hospital of Chinese Medicine from January 1, 2018, to December 31, 2021, were retrospectively enrolled. Through cox regression analysis, prognostic factors and independent prognostic factors affecting the efficacy of ICIs were identified, and a nomogram model was constructed. Hub cancer-related pain genes (CRPGs) were identified through bioinformatic analysis. Finally, the expression levels of hub CRPGs were detected using an enzyme-linked immunosorbent assay (ELISA).ResultsBefore PSM, a total of 222 patients were enrolled in this study. Univariate and multivariate cox analysis indicated that bone metastasis and NRS scores were independent prognostic factors for the efficacy of ICIs. After PSM, a total of 94 people were enrolled in this study. Univariate cox analysis and multivariate cox analysis indicated that age, platelets, Dnlr, liver metastasis, bone metastasis, and NRS scores were independent prognostic factors for the efficacy of ICIs. A nomogram was constructed based on 6 independent prognostic factors with AUC values of 0.80 for 1-year, 0.73 for 2-year, and 0.80 for 3-year survival. ELISA assay results indicated that the level of CXCL12 significantly decreased compared to baseline after pain was relieved.ConclusionBaseline pain is an independent prognostic factor affecting the efficacy of ICIs in lung cancer, potentially through CXCL12-mediated inflammation promotion and immunosuppression.