ABSTRACT Hepatocellular carcinoma (HCC) is the second most common cause of cancer-related death worldwide. Most patients with advanced HCC acquire sorafenib resistance. Drug resistance reflects the heterogeneity of tumors and is the main cause of tumor recurrence and death.We identified and validated sorafenib resistance related-genes (SRGs) as prognostic biomarkers for HCC. We obtained SRGs from the Gene Expression Omnibus and selected four key SRGs using the least absolute shrinkage and selection operator, random forest, and Support Vector Machine-Recursive feature elimination machine learning algorithms. Samples from the The Cancer Genome Atlas (TCGA)-HCC were segregated into two groups by consensus clustering. Following difference analysis, 19 SRGs were obtained through univariate Cox regression analysis, and a sorafenib resistance model was constructed for risk stratification and prognosis prediction. In multivariate Cox regression analysis, the risk score was an independent predictor of overall survival (OS). Patients classified as high-risk were more sensitive to other chemotherapy drugs and showed a higher expression of the common immune checkpoints. Additionally, the expression of drug-resistance genes was verified in the International Cancer Genome Consortium cohort. A nomogram model with a risk score was established, and its prediction performance was verified by calibration chart analysis of the TCGA-HCC cohort. We conclude that there is a significant correlation between sorafenib resistance and the tumor immune microenvironment in HCC. The risk score could be used to identify a reliable prognostic biomarker to optimize the therapeutic benefits of chemotherapy and immunotherapy, which can be helpful in the clinical decision-making for HCC patients.