Hepatocellular carcinoma (HCC) is one of the most common highly malignant tumours worldwide. FOXP3 and SQSTM1/P62 have been shown to be abnormally expressed in tumour cells, but their function in different tumours remains controversial. The present study was designed to evaluate the expression of FOXP3 and P62 in HCC and their prognostic value as well as their relationship with immune infiltration in HCC patients. The Gene Expression Omnibus (GEO) database and TNMplot.com platform were used to analyse the expression of FOXP3 and P62. The Cancer Genome Atlas (TCGA) database and Kaplan-Meier plotter were used to assess the impacts of FOXP3 and P62 on clinical prognosis. In addition, TCGA database was also used to examine the correlation between the expression of FOXP3 and P62 and tumour immune infiltration using the CIBERSORT algorithm. Finally, immunohistochemistry (IHC) was used to determine expression levels of FOXP3 and P62 in 89 HCC and adjacent normal liver tissues, and their effects on clinicopathological features and prognosis were verified. FOXP3 expression was downregulated in HCC tissues, while P62 expression was upregulated. FOXP3 underexpression and P62 overexpression were closely related to decreased overall survival (OS) in HCC patients. Additionally, the abnormal expression of FOXP3 and P62 was closely related to the infiltration levels of 12 types of immune cells, including regulatory T cells (Tregs), M2 macrophages, M0 macrophages, and CD8 T cells. Notably, in the validation model, abnormal FOXP3 and P62 expression was significantly associated with adverse clinicopathological factors in HCC patients, including elevated α-fetoprotein (AFP) levels, poor tumour differentiation, and increased Ki67 levels. Furthermore, low FOXP3 and high P62 expression were independent risk factors for predicting OS prognosis in HCC patients. FOXP3 and P62 have been shown to be important prognostic factors in HCC patients and are associated with immune cell infiltration in HCC. These findings suggest that FOXP3 and P62 may be valuable prognostic biomarkers and potential therapeutic targets for HCC treatment.