Tumor-associated macrophages (TAMs) having immunosuppressive properties are one of the most abundant immune cells in the tumor microenvironment (TME). Preclinical studies have highlighted the potential role of TAMs in resistance to immune checkpoint blockers (ICBs). Here, we investigated the predictive value of TAM infiltration in patients with non-small cell lung cancer (NSCLC) treated with ICBs and characterized their transcriptomic profiles. Tumor samples were collected from 152 patients with NSCLC before ICB treatment onset. After immunohistochemical staining and image analysis, the correlation between CD163+ cell infiltration and survival was analyzed. Spatial transcriptomic analyses were performed using the NanoString GeoMx Immune Pathways assay to compare the gene expression profile of tumors with high or low levels of CD163+ cell infiltration and to identify determinants of response to ICBs in tumors with high CD163+ infiltration. Low intratumoral CD163+ cell infiltration was associated with longer progression-free survival (PFS; HR 0.61, 95% CI 0.40 to 0.94, p=0.023) and overall survival (OS; HR 0.48, 95% CI 0.28 to 0.80, p=0.004) under ICB treatment. Spatial transcriptomic profiles of 16 tumors revealed the upregulation of ITGAM, CD27, and CCL5 in tumors with high CD163+ cell infiltration. Moreover, in tumors with high macrophage infiltration, the upregulation of genes associated with the interferon-γ signaling pathway and the M1 phenotype was associated with better responses under immunotherapy. Surprisingly, we found also a significantly higher expression of CSF1R in the tumors of responders. Analysis of three independent data sets confirmed that high CSF1R expression was associated with an increased durable clinical benefit rate (47% vs 6%, p=0.004), PFS (median 10.89 months vs 1.67 months, p=0.001), and OS (median 23.11 months vs 2.66 months, p<0.001) under ICB treatment. Enrichment of TAMs in the TME of NSCLC is associated with resistance to immunotherapy regardless of the programmed death ligand 1 status and is driven by upregulation of CD27, ITGAM, and CCL5 gene expression within the tumor compartment. Our transcriptomic analyses identify new potential targets to alter TAM recruitment/polarization and highlight the complexity of the CSF1R pathway, which may not be a suitable target to improve ICB efficacy.