Background. Gastric cancer (GC) represents a universal malignant tumor of the digestive system. Stromal and immune cells belong to two main nontumor components exerting a vital function in the tumor microenvironment. Methods. Based on TCGA database, this study downloaded clinical information and gene profiles of GC. The ESTIMATE algorithm was adopted for evaluating the score of immune-infiltrating cells. This work employed Sangerbox to explore the differentially denoted genes (DEGs) related to stromal, immunity, and prognosis. Besides, the STRING database was involved in order to detect the association among the proteins. The MCODE module of Cytoscape software was used to screen key genes. Oncomine and GEPIA databases were used, aiming to study the differences in key genes in healthy gastric mucosa and GC. At last, we adopted TISDIB and TIMER databases for analyzing the association of guanine nucleotide binding protein subunit-4 (GNB4) between gastric cancer and tumor immune cells. qRT-PCR was applied for exploring differential GNB4 expression between GC and normal gastric mucosa and investigating the relation of GNB4 with tumor-infiltrating lymphocytes (TILs). Results. Patients undergoing a great stromal score exhibited worse prognostic outcome, and cases having a low immune score had better prognosis. Overall, altogether 656 genes were upregulated with 5 genes being downregulated, which were matrix immune-related differential genes. Furthermore, 18 genes were screened as hub genes on the basis of the univariate Cox risk model of TCGA database (82 differential genes predicted poor GC survival). Oncomine and GEPIA databases revealed that GNB4 expression in gastric cancer was obviously higher in comparison with that in normal gastric mucosa. The GSEA, TISDIB, and TIMER databases revealed that GNB4 is involved in various tumor signal pathways and immune and metabolic processes. qRT-PCR demonstrated that GNB4 expression in gastric cancer was notably higher in comparison with that in normal gastric mucosa, showing significant association with matrix TILs. Conclusion. The selected key gene GNB4 is a potential biomarker to guide the immunotherapy of gastric cancer.