Background: Although intrinsic molecular subtype has been widely used, there remains great clinical heterogeneity of prognosis in the estrogen receptor (ER)- and/or progesterone receptor (PR)-positive and human epidermal growth factor receptor 2 (HER2)-negative breast cancer (BC).Methods: The transcriptome expression data of messenger RNA (mRNA) were downloaded from The Cancer Genome Atlas (TCGA), Molecular Taxonomy of Breast Cancer International Consortium (METABRIC), and the Gene Expression Omnibus (GEO) databases. Immune-related genes were acquired from the ImmPort database and additional literature search. Univariate Cox, LASSO regression, and multivariate Cox regression were used to screen prognostic immune-related genes and establish the risk signature. The correlation between the risk signature and clinical characteristics, the abundances of immune cells within the tumor microenvironment, and cancer phenotypes were further assessed.Results: Of note, 102 immune-related prognostic genes were identified in the METABRIC dataset by univariate Cox analysis. Consecutively, 7 immune-related genes (SHMT2, AGA, COL17A1, FLT3, SLC7A2, ATP6AP1, and CCL19) were selected to establish the risk signature by LASSO regression and multivariate Cox analysis. Its performance was further verified in TCGA and GSE21653 datasets. Multivariate Cox analysis showed that the risk signature was an independent prognostic factor. The 7-gene signature showed a significant correlation with intrinsic molecular subtypes and 70-gene signature. Furthermore, the CD4+ memory T cells were significantly higher in the low-risk group while a significantly higher proportion of M0-type macrophages was found in the high-risk group in both METABRIC and TCGA cohorts, which may have an influence on the prognosis. Furthermore, we found that the low-risk group may be associated with the immune-related pathway and the high-risk group was with the cell cycle-related pathway, which also showed an impact on the prognosis.Conclusion: These seven immune-related gene risk signatures provided an effective method for prognostic stratification in ER (+) and/or PR (+) and HER2 (−) BC.