Immune checkpoint inhibitor pneumonitis (CIP) is a prevalent form of immunotherapy-induced pulmonary toxicity, ranking among the leading causes of mortality associated with immune checkpoint inhibitors (ICIs). Despite its significance, the risk stratification of CIP in advanced non-small cell lung cancer (NSCLC) remains uncertain. In this study, we conducted a comprehensive analysis, comparing various factors such as histological types, treatment regimens, PD-L1 expression levels, and EGFR/ALK negativity in advanced NSCLC. Our investigation extends to evaluating the relative risk of developing CIP based on previous treatment history. This analysis aims to provide valuable insights for the identification of specific patient subgroups at higher risk, facilitating more effective risk management and precision therapy approaches. PubMed, Embase, and Cochrane databases were systematically searched up to February 16, 2023. We conducted a screening of randomized controlled trials (RCTs) that compared ICI monotherapy or its combination with chemotherapy in advanced NSCLC. The trials were categorized based on histological type, treatment regimen, PD-L1 expression level, EGFR/ALK-negative status, and prior treatment history. Subsequently, the data were stratified into five subgroups, and the occurrences of all-grades (1-5) and high-grades (3-5) pneumonia events were extracted. Odds ratios (OR) and corresponding 95% confidence intervals (CI) were then calculated for further analysis. Twenty-two RCTs, encompassing 13,725 patients with advanced NSCLC, were included in this analysis. Regardless of histology (OR = 2.47, 95% CI 1.41-4.33, P = 0.002; OR = 1.84, 95% CI 1.10-3.09, P = 0.02), treatment regimen (OR = 3.27, 95% CI 2.00-5.35, P < 0.00001; OR = 2.91, 95% CI 1.98-4.27, P < 0.00001), PD-L1 expression level (OR = 5.11, 95% CI 2.58-10.12, P < 0.00001; OR = 5.15, 95% CI 2.48-10.70, P < 0.0001), negative EGFR/ALK expression (OR = 4.32, 95% CI 2.22-8.41, P < 0.0001; OR = 3.6, 95% CI 1.56-8.28, P = 0.003), whether there is a history of treatment (OR = 3.27, 95% CI 2.00-5.35, P < 0.00001; OR = 2.74, 95% CI 1.75-4.29, P < 0.0001), ICI use was associated with a higher risk of all-grade (1-5) and high-grade (3-5) pneumonia compared to chemotherapy. Subgroup analysis revealed that the squamous group, the ICI vs. combination chemotherapy (CT) group, the PD-L1 > 50% group, and the previously untreated group had a higher risk of developing all-grade and grade 3-5 CIP (P < 0.05). In advanced NSCLC, ICI treatment was linked to an elevated risk of pneumonitis across all grades (1-5) as well as high-grade occurrences (3-5) compared to chemotherapy. Notably, individuals with squamous histology and high PD-L1 expression, along with those lacking a history of prior treatment, demonstrated a heightened susceptibility to developing immune-related pneumonitis of all grades (1-5) and high grades (3-5). These observations provide valuable insights for clinicians seeking to enhance the management of pulmonary toxicity associated with immunotherapy.