Macrophage polarization plays an essential role in tumor immune cells infiltration and tumor growth. We selected a series of genes distinguishing between M1 and M2 macrophage and explored their prognostic value in gliomas. A total of 170 genes were included in our study. CGGA database was used as the training cohort, and the TCGA database as the validation cohort. The biological processes and functions were identified by GO and KEGG analysis. Kaplan-Meier analysis was used to compare survival differences between groups. Finally, GEPIA was applied to explore immune infiltrates in the tumor microenvironment. Importantly, we re-verified the results using our sequencing data. We build a risk score model using Cox regression analysis based on the CGGA and verified in the TCGA database and our sequencing data. Patients with gliomas in the high-risk group were associated with high grade, IDH WT status, MGMT promoter unmethylation, 1p19q non-codeletion, and prone to have a poor outcome. Moreover, these genes play an essential role in immune infiltrations in LGG and GBM microenvironments. Macrophage polarization-related gene signature can predict the malignancy and outcome of patients with gliomas and might act as a promising target for glioma immunotherapy in the future.