Background: Idiopathic pulmonary fibrosis (IPF) is a type of interstitial lung disease characterized by unknown causes and a poor prognosis. Recent research indicates that age-related mechanisms, such as cellular senescence, may play a role in the development of this condition. However, the relationship between cellular senescence and clinical outcomes in IPF remains uncertain. Methods: Data from the GSE70867 database were meticulously analyzed in this study. The research employed differential expression analysis, as well as univariate and multivariate Cox regression analysis, to pinpoint senescence-related genes (SRGs) linked to prognosis and construct a prognostic risk model. The model’s clinical relevance and its connection to potential biological processes were systematically assessed in training and testing datasets. Additionally, the expression location of prognosis-related SRGs was identified through immunohistochemical staining, and the correlation between SRGs and immune cell infiltration was deduced using the GSE28221 dataset. Result: The prognostic risk model was constructed based on five SRGs (cellular communication network factor 1, CYR61, stratifin, SFN, megakaryocyte-associated tyrosine kinase, MATK, C-X-C motif chemokine ligand 1, CXCL1, LIM domain, and actin binding 1, LIMA1). Both Kaplan-Meier (KM) curves (p = 0.005) and time-dependent receiver operating characteristic (ROC) analysis affirmed the predictive accuracy of this model in testing datasets, with respective areas under the ROC curve at 1-, 2-, and 3-years being 0.721, 0.802, and 0.739. Furthermore, qRT-RCR analysis and immunohistochemical staining verify the differential expression of SRGs in IPF samples and controls. Moreover, patients in the high-risk group contained higher infiltration levels of neutrophils, eosinophils, and M1 macrophages in BALF, which appeared to be independent indicators of poor prognosis in IPF patients. Conclusion: Our research reveals the effectiveness of the 5 SRGs model in BALF for risk stratification and prognosis prediction in IPF patients, providing new insights into the immune infiltration of IPF progression.