Hepatocellular carcinoma (HCC) can have viral or non-viral causes1–5. Non-alcoholic steatohepatitis (NASH) is an important driver of HCC. Immunotherapy has been approved for treating HCC, but biomarker-based stratification of patients for optimal response to therapy is an unmet need6,7. Here we report the progressive accumulation of exhausted, unconventionally activated CD8+PD1+ T cells in NASH-affected livers. In preclinical models of NASH-induced HCC, therapeutic immunotherapy targeted at programmed death-1 (PD1) expanded activated CD8+PD1+ T cells within tumours but did not lead to tumour regression, which indicates that tumour immune surveillance was impaired. When given prophylactically, anti-PD1 treatment led to an increase in the incidence of NASH–HCC and in the number and size of tumour nodules, which correlated with increased hepatic CD8+PD1+CXCR6+, TOX+, and TNF+ T cells. The increase in HCC triggered by anti-PD1 treatment was prevented by depletion of CD8+ T cells or TNF neutralization, suggesting that CD8+ T cells help to induce NASH–HCC, rather than invigorating or executing immune surveillance. We found similar phenotypic and functional profiles in hepatic CD8+PD1+ T cells from humans with NAFLD or NASH. A meta-analysis of three randomized phase III clinical trials that tested inhibitors of PDL1 (programmed death-ligand 1) or PD1 in more than 1,600 patients with advanced HCC revealed that immune therapy did not improve survival in patients with non-viral HCC. In two additional cohorts, patients with NASH-driven HCC who received anti-PD1 or anti-PDL1 treatment showed reduced overall survival compared to patients with other aetiologies. Collectively, these data show that non-viral HCC, and particularly NASH–HCC, might be less responsive to immunotherapy, probably owing to NASH-related aberrant T cell activation causing tissue damage that leads to impaired immune surveillance. Our data provide a rationale for stratification of patients with HCC according to underlying aetiology in studies of immunotherapy as a primary or adjuvant treatment.