Abstract Introduction: In gastric cancer, studies of tumor infiltrating lymphocytes as a prognostic biomarker show contradictory results. These results may be caused by use of variable immunohistochemistry (IHC) quantification techniques, different marker selections and particularly inconsistency in the evaluated tumor regions. To overcome these issues, we performed a comprehensive digital image analysis of 5 immune cell markers for their prognostic value in a cohort of gastric cancer patients who were treated with surgery only in the Dutch D1/D2 trial. Methods: All available surgical resection specimens of gastric cancer patients were included in this study (N=251). IHC for T-cell markers CD3, CD45RO, CD8, FOXP3 and Granzyme B was performed on serial slides. After manual annotation of the tumor area, an invasive margin was defined as 0.5 mm into the tumor still containing tumor cells (inner margin, IM) and 0.5 mm outside of the tumor not containing tumor cells (outer margin, OM). The density of positive immune cells (cells/mm2) was digitally quantified using QuPath for each 0.5x0.5 mm2 square across tumor center (TC), IM and OM, separately. A classification and regression tree (CART) model was employed to identify an optimal combination of prognostic markers from the continuous immune cell density variables with cancer specific survival (CSS) as outcome. Results: The CART decision tree identified CD8 OM (≥798 cells/mm2) as most dominant prognostic factor, followed by FOXP3 TC (≥20 cells/mm2) in the CD8 OM low subset. This resulted in 3 CART branches in the decision tree: CD8 OM high with best prognosis, CD8 OM low/FOXP3 TC high with intermediate prognosis, and CD8 OM low/FOXP3 TC low with worst prognosis (Log-rank P-value <0.0001). The CD8 OM high branch was enriched in EBV+ (38.2%) and MSI-high (17.6%) tumors, compared to the other two branches with poorer prognosis (4.2% and 3.4% for EBV+, 7.9% and 8.4% for MSI-high). The CART model was an independent predictor of CSS in a multivariable cox-regression (HR branch 2 vs 1: 4.87, 95% CI 1.96-12.07 and HR branch 3 vs 1: 7.97, 95% CI 3.20-19.86), which included T stage, N stage, Lauren subtype, EBV-status and MSI-status. The performance of the CART model was assessed by 5-fold cross-validation, where 4 out of 5 models reached a P-value < 0.05 (Likelihood-Ratio test). Conclusions: The OM in gastric cancer contains previously overlooked important prognostic information valuable for immune biomarker studies. The combination of CD8 OM and FOXP3 TC is identified as strongest prognostic factor in the risk stratification of resectable gastric cancer, and is independent of T stage, N stage, EBV-status, MSI-status and Lauren subtype. Moreover, high T-cell densities found in a proportion of EBV-/MSS tumors support further investigation of response to immunotherapy in these subgroups. Citation Format: Tanya T. Soeratram, Hedde D. Biesma, Jacqueline M. Egthuijsen, Elma Meershoek-Klein Kranenbarg, Henk H. Hartgrink, Cornelis J. van de Velde, Erik van Dijk, Yongsoo Kim, Bauke Ylstra, Hanneke W. van Laarhoven, Nicole C. van Grieken. CD8+ T cells in the invasive margin combined with FOXP3+ T cells in the tumor center significantly associate with survival in resectable gastric cancer, a post-hoc analysis of the Dutch D1/D2 trial [abstract]. In: Proceedings of the American Association for Cancer Research Annual Meeting 2022; 2022 Apr 8-13. Philadelphia (PA): AACR; Cancer Res 2022;82(12_Suppl):Abstract nr 1727.