The current research investigated the heterogeneity of hepatocellular carcinoma (HCC) based on the expression of N7-methylguanosine (m7G)-related genes as a classification model and developed a risk model predictive of HCC prognosis, key pathological behaviors and molecular events of HCC. The RNA sequencing data of HCC were extracted from The Cancer Genome Atlas (TCGA)-live cancer (LIHC) database, hepatocellular carcinoman database (HCCDB) and Gene Expression Omnibus database, respectively. According to the expression level of 29 m7G-related genes, a consensus clustering analysis was conducted. The least absolute shrinkage and selection operator (LASSO) regression analysis and COX regression algorithm were applied to create a risk prediction model based on normalized expression of five characteristic genes weighted by coefficients. Tumor microenvironment (TME) analysis was performed using the MCP-Counter, TIMER, CIBERSORT and ESTIMATE algorithms. The Tumor Immune Dysfunction and Exclusion algorithm was applied to assess the responses to immunotherapy in different clusters and risk groups. In addition, patient sensitivity to common chemotherapeutic drugs was determined by the biochemical half-maximal inhibitory concentration using the R package pRRophetic. Three molecular subtypes of HCC were defined based on the expression level of m7G-associated genes, each of which had its specific survival rate, genomic variation status, TME status and immunotherapy response. In addition, drug sensitivity analysis showed that the C1 subtype was more sensitive to a number of conventional oncolytic drugs (including paclitaxel, imatinib, CGP-082996, pyrimethamine, salubrinal and vinorelbine). The current five-gene risk prediction model accurately predicted HCC prognosis and revealed the degree of somatic mutations, immune microenvironment status and specific biological events. In this study, three heterogeneous molecular subtypes of HCC were defined based on m7G-related genes as a classification model, and a five-gene risk prediction model was created for predicting HCC prognosis, providing a potential assessment tool for understanding the genomic variation, immune microenvironment status and key pathological mechanisms during HCC development.