Gastric cancer, a pervasive malignancy globally, often presents with regional lymph node metastasis (LNM), profoundly impacting prognosis and treatment options. Existing clinical methods for determining the presence of LNM are not precise enough, necessitating the development of an accurate risk prediction model. Our primary objective was to employ machine learning algorithms to identify risk factors for LNM and establish a precise prediction model for stage II-III gastric cancer. A study was conducted at Renji Hospital Affiliated to Shanghai Jiao Tong University School of Medicine between May 2010 and December 2022. This retrospective study analyzed 1147 surgeries for gastric cancer and explored the clinicopathological differences between LNM and non-LNM cohorts. Utilizing univariate logistic regression and two machine learning methodologies-Least absolute shrinkage and selection operator (LASSO) and random forest (RF)-we identified vascular invasion, maximum tumor diameter, percentage of monocytes, hematocrit (HCT), and lymphocyte-monocyte ratio (LMR) as salient factors and consolidated them into a nomogram model. The area under the receiver operating characteristic (ROC) curve (AUC), calibration curves, and decision curves were used to evaluate the test efficacy of the nomogram. Shapley Additive Explanation (SHAP) values were utilized to illustrate the predictive impact of each feature on the model's output. Significant differences in tumor characteristics were discerned between LNM and non-LNM cohorts through appropriate statistical methods. A nomogram, incorporating vascular invasion, maximum tumor diameter, percentage of monocytes, HCT, and LMR, was developed and exhibited satisfactory predictive capabilities with an AUC of 0.787 (95% CI: 0.749-0.824) in the training set and 0.753 (95% CI: 0.694-0.812) in the validation set. Calibration curves and decision curves affirmed the nomogram's predictive accuracy. In conclusion, leveraging machine learning algorithms, we devised a nomogram for precise LNM risk prognostication in stage II-III gastric cancer, offering a valuable tool for tailored risk assessment in clinical decision-making.