Cancer immunotherapy has achieved positive clinical responses in the treatment of various cancers, including gastric cancer (GC). In this study, we characterized the heterogeneity of T cells isolated from GC patients at the single-cell level using single-cell RNA sequencing. We identified different immune cell subtypes and their heterogeneous transcription factors and depicted their developmental trajectories. In particular, we focused on exhausted CD8+ cells and Tregs and discovered that, as compared to control, the IRF8 transcription factor was downregulated in CD8+ tumour-infiltrating lymphocytes (TILs) from GC tissues, and that GC patients with lower IRF8 levels in blood CD8+ T cells tended to be a at a more advanced disease stage. These findings provide a theoretical basis for targeted immune therapy in GC.