Mounting evidence suggests that immune cell infiltration within the tumor microenvironment (TME) is a crucial regulator of carcinogenesis and therapeutic efficacy in ovarian cancer (OC). In this study, 593 OC patients from TCGA were divided into high and low score groups based on their immune/stromal scores resulting from analysis utilizing the ESTIMATE algorithm. Differential expression analysis revealed 294 intersecting genes that influencing both the immune and stromal scores. Further Cox regression analysis identified 34 differentially expressed genes (DEGs) as prognostic-related genes. Finally, the nine-gene signature was derived from the prognostic-related genes using a Least Absolute Shrinkage and Selection Operator (LASSO) and Cox regression. This nine-gene signature could effectively distinguish the high-risk patients in the training (TCGA database) and validation (GSE17260) cohorts (all p < 0.01). A time-dependent receiver operating characteristic (ROC) analysis showed that the nine-gene signature had a reasonable predictive accuracy (AUC = 0.707, AUC =0.696) in both cohorts. In addition, this nine-gene signature is associated with immune infiltration in TME by Gene Set Variation Analysis (GSVA), and can be used to predict the survival of patients with OC.