Objective: Epstein–Barr virus (EBV) and Helicobacter pylori (HP) infections have been extensively recognised as gastric cancer (GC) triggers, and recent publications suggest they could behave as predictive markers for immune-modulating therapies. Tumour-infiltrating lymphocytes (TILs) have also been identified as a predictive biomarker for immunotherapy in different malignancies. This study aimed to investigate the association between EBV and HP infection with TIL levels in GC. Methods: TIL evaluation in haematoxylin-eosin was performed by a pathologist and density of CD3, CD8 and CD163 positive (immunohistochemistry staining) immune cells was calculated with the use of digital pathology software. EBV infection was detected by in situ hybridisation (ISH) and by quantitative polymerase chain reaction (qPCR). Methylation status of EBV-related genes was detected by PCR and a methylome analysis was performed by the Illumina Infinium MethylationEPIC BeadChip. HP status was detected by qPCR. Results: We included 98 resected GC Peruvian cases in our evaluation. Median TIL percentage was 30. The proportion of EBV+ detected by ISH was 24.1%, of EBV+ detected by qPCR was 41.8%, while 70% showed methylation of EBV-related genes, and 58.21% of cases were HP+. Younger age (p = 0.024), early stages (p = 0.001), HP+ (p = 0.036) and low CD8 density (p = 0.046) were associated with longer overall survival (OS). High TIL level was associated with intestinal subtype (p < 0.001), with grade 2 (p < 0.001), with EBV qPCR+ (p = 0.001), and with methylation of EBV-related genes (p = 0.007). Cases with high TIL level and cases that are EBV positive share eight genes with similarly methylated status in the metabolomic analysis. High CD8 density was associated with EBV PCR+ (p = 0.012) and HP− (0.005). Conclusion: Lower CD8 density and HP+ predict longer OS. High TIL level is associated with EBV+ and methylation of EBV-related genes, while lower CD8 density is associated with HP+ GC.