Introduction: Hepatocellular carcinoma (HCC) is one of the most common malignant tumors with poor prognosis. The tumor microenvironment (TME) plays a vital role in HCC progression. Thus, this research was designed to analyze the correlation between the TME and the prognosis of HCC patients and to construct a TME-related long noncoding RNA (lncRNA) signature to determine HCC patients’ prognosis and response to immunotherapy. Methods: We assessed the stromal–immune–estimate scores within the HCC microenvironment using the ESTIMATE (Estimation of Stromal and Immune Cells in Malignant Tumor Tissues Using Expression Data) algorithm based on The Cancer Genome Atlas database, and their associations with survival and clinicopathological parameters were also analyzed. Thereafter, differentially expressed lncRNAs were filtered out according to the immune and stromal scores. Cox regression analysis was performed to build a TME-related lncRNA risk signature. Kaplan–Meier analysis was used to explore the prognostic value of the risk signature. Furthermore, we explored the biological functions and immune microenvironment features in the high- and low-risk groups. Lastly, we probed the association of the risk model with treatment responses to immune checkpoint inhibitors (ICIs) in HCC. Results: The stromal, immune, and estimate scores were obtained utilizing the ESTIMATE algorithm for patients with HCC. Kaplan–Meier analysis showed that high scores were significantly correlated with better prognosis in HCC patients. Six TME-related lncRNAs were screened to construct the prognostic model. The Kaplan–Meier curves suggested that HCC patients with low risk had better prognosis than those with high risk. Receiver operating characteristic (ROC) curve and Cox regression analyses indicated that the risk model could predict HCC survival exactly and independently. Functional enrichment analysis revealed that some tumor- and immune-related pathways were activated in the high-risk group. We also revealed that some immune cells, which were important in enhancing immune responses toward cancer, were significantly increased in the low-risk group. In addition, there was a close correlation between ICIs and the risk signature, which can be used to predict the treatment responses of HCC patients. Conclusion: We analyzed the influence of the stromal, immune, and estimate scores on the prognosis of HCC patients. A novel TME-related lncRNA risk model was established, which could be effectively applied as an independent prognostic biomarker and predictor of ICIs for HCC patients.