The prognostic value of immune cells in tertiary lymphoid structures (TLSs) remains unclear in hepatocellular carcinoma (HCC). Here, 59 of 145 patients had TLSs in training set, 48 of 120 patients had TLSs in testing set. Immunohistochemistry (IHC) were used to label CD3+ T cells, CD20+ B cells, CD8+ T cells, CD208+ dendritic cells, and CD21+ follicular dendritic cells in TLSs. High CD20+, CD208+, and CD8+ cell densities were favorable prognostic factors for overall survival (OS). High CD3+, CD20+, CD208+, and CD8+ cell densities were significantly associated with reduced early recurrence. TLSs were divided into three grades (A, B, and C) based on immune cell density. Patients with grade C or B had significantly improved OS. Patients with grade C had the lowest recurrence rate, followed by those with grade B, while patients with grade A had the highest recurrence rate. The stromal, immune, and ESTIMATE scores derived from the ESTIMATE package were significantly higher and tumor purity was significantly lower in patients with TLSs. Patients with TLSs had significantly higher relative numbers of memory B cells, plasma cells, CD8+ T cells, NK cells, and dendritic cells and lower relative numbers of Treg cells, macrophages, and M2 macrophages according to the CIBERSORT assessment. Bioinformatics analysis and experiments confirmed that KLRK1 and GZMA expression are associated TLSs formation and can predict TLSs existence. Grade B and grade C were favorable prognostic factors for OS and recurrence and could represent immune-active tumors.