BackgroundImmune-related genes have been used as prognostic markers in multiple types of tumors. We aimed to develop an immune-related gene signature for predicting individual lymph node metastasis in gastric cancer (GC) patients, characterize the molecular and immune profiles of different risk patients and assess the potential value of this signature identifying patients with response to immune checkpoint inhibitor (ICI) treatment.MethodsA total of 1338 GC patients from a training dataset, three external silico validation datasets and an external clinical dataset were included in this study. The microarray analysis was used to detect differentially expressed immune-related genes (DEIGs) between lymph node metastatic and non-lymph node metastatic gastric cancer tissues. Subsequently, we built a lymph node metastasis gene signature for gastric cancer (LGSGC), and then classified patients into low-risk and high-risk groups according to the LGSGC. Moreover, we implemented association analysis for this signature and the prognosis, molecular characteristics, immune profiles and the response of ICI treatment in different risk GC patients. Resultshe receiver operating characteristics (ROC) curve analysis (an area under curve [AUC] values of 0.85) showed that the LGSGC could distinguish lymph node metastatic patients from non-lymph node metastatic patients in the training dataset. Additionally, compared to low-risk group, high-risk group exhibited worse overall survival (hazard ratio [HR]=2.42) in the training dataset. Robust diagnostic and prognostic clinical ability of the LGSGC were successfully validated in four validation datasets. Next, the high-risk patients were characterized by active cancer and immune response-related pathways, high TP53, CSMD3 and FAT4 mutation rate, high infiltration of Neutrophils, M1 Macrophages, M0 Macrophages, M2 Macrophages, T cells gamma delta and T cells follicular helper, more abundant check point, more aggressive inflammation and Type I IFN response, and more benefit from ICI. On the contrary, low-risk patients were characterized by active cancer and tumor metabolism-related pathways, low TP53 mutation rate, high infiltration of Mast cells resting, NK cells resting, Plasma cells and T cells CD4 memory resting, and less benefit from ICI therapy. Of note, we also validated the LGSGC, which identified patients having response to ICI treatment with an AUC value of 0.71 in an advanced GC dataset and an AUC value of 0.64 in an IMvigor210 dataset. ConclusionsThe LGSGC is a reliable indicator to distinguish LNM in GC and could discriminate the prognosis, molecular characteristics, immune profiles and the response of ICI treatment in different risk groups. This signature may provide a reference for treatment decisions for different risk GC patients.