Background Tumor microenvironment (TME) and immune checkpoint inhibitors has been shown to promote active immune responses through different mechanisms. We aimed to identify the important prognostic genes and prognostic characteristics related to TME in prostate cancer (PCa).Methods The gene transcriptome profiles and clinical information of PCa patients were obtained from the TCGA database, and the immune, stromal and estimate scores were calculated by the ESTIMATE algorithm. We evaluated the prognostic value of risk score (RS) model based on univariate Cox and LASSO Cox regression models analysis, and established a nomogram to predict disease-free survival (DFS) in PCa patients. The GSE70768 data set was used for external validation. Finally, 22 subsets of tumor-infiltrating immune cells (Tiics) were analyzed using the Cibersort algorithm.Results In this study, the patients with higher immune, stromal, and estimate scores were associated with poorer DFS, higher Gleason score, and higher AJCC T stage. Based on the immune and stromal scores, the Venny diagram screened out 515 cross DEGs. The univariate COX and Lasso Cox regression models were used to select 18 DEGs from 515 DEGs, and constructed a RS model. The DFS of the high-RS group was significantly lower than that of the low-RS group (P<0.001). The AUC of 1-year, 3-year and 5-year DFS rates in RS model were 0.778, 0.754 and 0.750, respectively. In addition, the RS model constructed from 18 genes was found to be more sensitive than Gleason score (1, 3, 5 year AUC= 0.704, 0.677 and 0.682). The nomograms of DFS were established based on RS and Gleason scores. The AUC of the nomograms in the first, third, and fifth years were 0.802, 0.808, and 0.796, respectively. These results have been further validated in GEO. In addition, the proportion of Tregs was higher in high-RS patients (P<0.05), and the expression of five immune checkpoints (CTLA-4, PD-1, LAG-3, TIM-3 and TIGIT) was higher in high-RS patients (P<0.05).Conclusion We identified 18 TME-related genes from the TCGA database, which were significantly related to DFS in PCa patients.