BackgroundHomologous recombination repair (HRR) plays an important role in cancer development, drug resistance, and immune escape, but the role of HRR genes in primary lung cancer (PLC) after previous malignancies is unclear.MethodsWe used HRR‐related score constrcted by HRR genes to classify patients into two groups and compared clinical progression, differential genes, and their functions between them. Then, we constructed a prognostic risk model based on HRR‐related score and screened key differentially expressed genes. We evaluated the potential roles, mutational information, and immune correlations of key genes. Finally, we compared the long‐term prognosis and immune correlations of different prognostic risk subgroups.ResultsWe found that HRR‐related score was associated with T‐stage, immunotherapy sensitivity, and prognosis of PLC after previous malignancies. Differential genes between HRR‐related low‐score and high‐score groups are mainly involved in DNA replication and repair processes, such as the cell cycle. We identified three key genes, ABO, SERPINE2, and MYC, by machine learning, and MYC had the highest amplification mutation frequency. We verified that the key gene‐based prognostic model can better assess the prognosis of patients. The risk score of the prognostic model was associated with immune microenvironment and efficacy of immunotherapy.ConclusionsOverall, we identified three key genes ABO, SERPINE2, and MYC associated with HRR status in PLC after previous malignancies. The risk model based on key genes is associated with immune microenvironment and can well predict the prognosis for PLC after previous malignancies.