Hepatocellular carcinoma (HCC) represents a complex ailment characterized by an unfavorable prognosis in advanced stages. The involvement of immune cells in HCC progression is of significant importance. Moreover, metastasis poses a substantial impediment to enhanced prognostication for HCC patients, with anoikis playing an indispensable role in facilitating the distant metastasis of tumor cells. Nevertheless, limited investigations have been conducted regarding the utilization of anoikis factors for predicting HCC prognosis and assessing immune infiltration. This present study aims to identify hepatocellular carcinoma-associated anoikis-related genes (ANRGs), establish a robust prognostic model for HCC, and delineate distinct immune characteristics based on the anoikis signature. Cell migration and cytotoxicity experiments were performed to validate the accuracy of the ANRGs model. Consensus clustering based on ANRGs was employed in this investigation to categorize HCC samples obtained from both TCGA and Gene Expression Omnibus (GEO) cohorts. To assess the differentially expressed genes, Cox regression analysis was conducted, and subsequently, prognostic gene signatures were constructed using LASSO-Cox methodology. External validation was performed at the International Cancer Genome Conference. The tumor microenvironment (TME) was characterized utilizing ESTIMATE and CIBERSORT algorithms, while machine learning techniques facilitated the identification of potential target drugs. The wound healing assay and CCK-8 assay were employed to evaluate the migratory capacity and drug sensitivity of HCC cell lines, respectively. Utilizing the TCGA-LIHC dataset, we devised a nomogram integrating a ten-gene signature with diverse clinicopathological features. Furthermore, the discriminative potential and clinical utility of the ten-gene signature and nomogram were substantiated through ROC analysis and DCA. Subsequently, we devised a prognostic framework leveraging gene expression data from distinct risk cohorts to predict the drug responsiveness of HCC subtypes. In this study, we have established a promising HCC prognostic ANRGs model, which can serve as a valuable tool for clinicians in selecting targeted therapeutic drugs, thereby improving overall patient survival rates. Additionally, this model has also revealed a strong connection between anoikis and immune cells, providing a potential avenue for elucidating the mechanisms underlying immune cell infiltration regulated by anoikis.