<b><i>Background:</i></b> Reversal of CD8 T-cell exhaustion was considered a major antitumor mechanism of anti-programmed cell death-1 (PD-1)/ anti-programmed death ligand-1 (PD-L1)-based immune checkpoint inhibitor (ICI) therapy. <b><i>Objectives:</i></b> The aim of this study was to identify markers of T-cell exhaustion that is best associated with ICI treatment efficacy for advanced hepatocellular carcinoma (HCC). <b><i>Methods:</i></b> Immune cell composition of archival tumor samples was analyzed by transcriptomic analysis and multiplex immunofluorescence staining. <b><i>Results:</i></b> HCC patients with objective response after anti-PD-1/anti-PD-L1-based ICI therapy (<i>n</i> = 42) had higher expression of genes related to T-cell exhaustion. A 9-gene signature (LAG3, CD244, CCL5, CXCL9, CXCL13, MSR1, CSF3R, CYBB, and KLRK1) was defined, whose expression was higher in patients with response to ICI therapy, correlated with density of CD8<sup>+</sup>LAG3<sup>+</sup> cells in tumor microenvironment, and independently predicted better progression-free and overall survival. This 9-gene signature had similar predictive values for patients who received single-agent or combination ICI therapy and was not associated with prognosis in HCC patients who received surgery, suggesting that it may outperform other T-cell signatures for predicting efficacy of ICI therapy for HCC. For HCC patients who underwent surgery for both the primary liver and metastatic lung tumors (<i>n</i> = 31), lung metastatic HCC was associated with a higher exhausted CD8 T-cell signature, consistent with prior observation that patients with lung metastatic HCC may have higher probability of response to ICI therapy. <b><i>Conclusions:</i></b> CD8 T-cell exhaustion in tumor microenvironment may predict better efficacy of ICI therapy for HCC.