The protein encoded by CD3D is part of the T-cell receptor/CD3 complex (TCR/CD3 complex) and is involved in T-cell development and signal transduction. Previous studies have shown that CD3D is associated with prognosis and treatment response in breast, colorectal, and liver cancer. However, the expression and clinical significance of CD3D in gastric cancer are not clear. In this study, we collected 488 gastric cancer tissues and 430 paired adjacent tissues to perform tissue microarrays (TMAs). Then, immunohistochemical staining of CD3D, CD3, CD4, CD8 and PD-L1 was conducted to investigate the expression of CD3D in gastric cancer and the correlation between the expression of CD3D and tumor infiltrating lymphocytes (TILs) and PD-L1. The results showed that CD3D was highly expressed in gastric cancer tissues compared with paracancerous tissues (P<0.000). Univariate and multivariate analyses showed that CD3D was an independent good prognostic factor for gastric cancer (P=0.004, HR=0.677, 95%CI: 0.510-0.898 for univariate analyses; P=0.046, HR=0.687, 95%CI: 0.474-0.994 for multivariate analyses). In addition, CD3D was negatively correlated with the tumor location, Borrmann type and distant metastasis (P=0.012 for tumor location; P=0.007 for Borrmann type; P=0.027 for distant metastasis). In addition, the expression of CD3D was highly positively correlated with the expression of CD3, CD4, CD8, and PD-L1, and the combination of CD3D with CD3, CD4, CD8 and PD-L1 predicted the best prognosis (P=0.043). In summary, CD3D may play an important regulatory role in the tumor immune microenvironment of gastric cancer and may serve as a potential indicator of prognosis and immunotherapy response.