Objective To analyze the causal relationship between immune cell phenotype and gastric cancer. Methods Bidirectional two-sample Mendelian randomization (MR) analysis was used to select 731 genetic variants involving immune cell phenotypes from the GWAS dataset as instrumental variables. Inverse-variance weighting method (IVW), weighted median method (WM), and MR-Egger regression were used for sensitivity analysis. Cochran Q test, MR-Egger regression, MR-PRESSO method, and remain-one method were also conducted. Results Changes in the absolute count of IgD+ B cells and CD14-CD16- cells were significantly associated with the risk of gastric cancer. A lower proportion of IgD+ B cells was associated with a lower risk of gastric cancer (OR=0.86, 95%CI: 0.79-0.94), while an increased number of CD4-CD8-T cells was associated with an increased risk of gastric cancer (OR=1.2, 95%CI: 1.1-1.3). Conclusion A causal relationship exists between immune cell phenotype and the risk of gastric cancer. Changes in specific immune markers may regulate the development of gastric cancer by affecting the tumor microenvironment.