To investigate the prognostic value of M2 macrophage-related genes (MRG) in hepatitis B virus (HBV)- related hepatocellular carcinoma (HCC). The transcriptome data of 73 patients with HBV-related HCC were obtained from TCGA database, and the MRG modules were identified by WGCNA. The MRG-based risk scoring model was constructed by LASSO regression analysis and validated using an external dataset. The correlation of the risk score with immune cell infiltration and drug sensitivity of HCC were analyzed with CIBERSORT and R. pRRophetic. The signaling pathways of the differential genes between the high- and low-risk groups were investigated using GSVA and GSEA enrichment analyses, and MRG expressions at the single cell level were validated using R.Seurat. The cell interaction intensity was analyzed by R.Cellchat to identify important cell types related to HCC progression. MRG expression levels were detected by RT-qPCR in THP-1 cells with HCC-conditioned medium-induced M2 polarization and in HBV-positive HCC cells. A high M2 macrophage infiltration level was significantly correlated with a poor prognosis of HCC, and 5 hub MRG (VTN, GCLC, PARVB, TRIM27, and GMPR) were identified. The overall survival of HCC patients was significantly lower in the high-risk than in the low-risk group. The high- and the low-risk groups showed significant enrichment of M2 macrophages and na?ve B cells, respectively, and were sensitive to BI. 2536 and to AG. 014699, AKT. inhibitor. Ⅷ, AZD. 0530, AZD7762, and BMS. 708163, respectively. The proliferation-related and metabolism-related pathways were enriched in the high-risk group, where monocytes showed the most active cell interactions during HCC progression. VTN was significantly upregulated in HCC cell lines, while GCLC, PARVB, TRIM27, and GMPR were upregulated in M2 THP-1 cells. The MRG-based risk scoring model can accurately predict the prognosis of HBV-related HCC and reveal the differences in tumor microenvironment to guide precision treatment of the patients.