Genetic aberrations and immune escape are fundamental in MDS and CMML initiation and progression to sAML. Therefore, quantitative and spatial immune cell organization, expression of immune checkpoints (ICP), classical human leukocyte antigen class I (HLA-I) and the non-classical HLA-Ib antigens were analyzed in 274 neoplastic and 50 non-neoplastic bone marrow (BM) biopsies using conventional and multiplex immunohistochemistry and correlated to publicly available dataset. Higher numbers of tissue infiltrating lymphocytes (TILs) were found in MDS/CMML (8.8%) compared to sAML (7.5%) and non-neoplastic BM (5.3%). Higher T cell abundance, including the CD8+ T cell subset, inversely correlated with the number of pathogenic mutations and was associated with blast BM counts, ICP expression, spatial T cell distribution and improved patients' survival in MDS and CMML. In MDS/CMML, higher PD-1/PD-L1/PD-L2 and HLA-I, but lower HLA-G expression correlated with a significantly better patients' outcome. Moreover, a closer spatial proximity of T cell subpopulations and their proximity to myeloid blasts showed a stronger prognostic impact when compared to TIL numbers. In sAML - the continuum of MDS and CMML - the number of TILs had no impact on prognosis, but higher CD28 and HLA-I expression correlated with a better outcome of sAML patients. This study underlines the independent prognostic value of the tumor microenvironment in MDS/CMML progression to sAML, which shows the most pronounced immune escape. Moreover, new prognostic markers, like HLA-G expression and spatial T cell distribution, were described for the first time, which might also serve as therapeutic targets.