T cell‒mediated rejection (TCMR) and antibody‐mediated rejection (ABMR) are severe post‐transplantation complications for heart transplantation (HTx), whose molecular and immunological pathogenesis remains unclear. In the present study, the mRNA microarray data set GSE124897 containing 645 stable, 52 TCMR and 144 ABMR endomyocardial biopsies was obtained to screen for differentially expressed genes (DEGs) between rejected and stable HTx samples and to investigate immune cell infiltration. Functional enrichment analyses indicated roles of the DEGs primarily in immune‐related mechanisms. Protein‐protein interaction networks were then constructed, and ICAM1, CD44, HLA‐A and HLA‐B were identified as hub genes using the maximal clique centrality method. Immune cell infiltration analysis revealed differences in adaptive and innate immune cell populations between TCMR, ABMR and stable HTx samples. Additionally, hub gene expression levels significantly correlated with the degree and composition of immune cell infiltration in HTx rejection samples. Furthermore, drug‐gene interactions were constructed, and 12 FDA‐approved drugs were predicted to target hub genes. Finally, an external GSE2596 data set was used to validate the expression of the hub genes, and ROC curves indicated all four hub genes had promising diagnostic value for HTx rejection. This study provides a comprehensive perspective of molecular and immunological regulatory mechanisms underlying HTx rejection.