BackgroundHepatocellular carcinoma (HCC), theseventh most common cancer worldwide, is characterized by a high mortality rate, advanced diagnosis, and susceptibility to extrahepatic metastasis. Numerous studies have shown that DNA methylation is a crucial factor in epigenetic modifications and regulation of carcinogenesis. MethodsHCC patient data were sourced from the TCGA dataset as a training set, while GSE116174 was used as an external validation set for verification. Differential methylation and expression analyses were performed on HCC samples with and without extrahepatic metastasis. In the intersecting genes, the relationship between methylation and expression levels of the intersecting genes was analyzed. Genes with a correlation coefficient≥|0.30| and P<0.05 were identified as methylation driver genes. Cox regression analysis was conducted to identify genes associated with HCC prognosis and establish a risk score. Subsequently, a prognostic model was established and validated using Cox regression analysis incorporating the risk score and other clinical factors. Using immunohistochemistry to evaluate the expression of DHX58 and EIF5A2 in HCC tissues with and without extrahepatic metastasis. Immunoinfiltration analysis was performed on the HCC samples using CIBERSORT. ResultsOur research identified eight methylation driver genes for HCC extrahepatic metastasis, of which two genes (DHX58 and EIF5A2) were associated with HCC patient prognosis. And the study further constructed and validated the risk score and prognostic model. Immunoinfiltration analysis showed that M0 macrophage abundance was correlated with the prognosis of HCC patients. Immunohistochemistry revealed differences in DHX58 and EIF5A2 expression between HCC tissues with and without extrahepatic metastasis, consistent with our bioinformatics findings.