Idiopathic pulmonary fibrosis (IPF) risk has a strong genetic component. Studies have implicated variations at several loci, including TERT, surfactant genes, and a single nucleotide polymorphism at chr11p15 (rs35705950) in the intergenic region between TOLLIP and MUC5B. Patients with IPF who have risk alleles at rs35705950 have longer survival from the time of IPF diagnosis than do patients homozygous for the non-risk allele, whereas patients with shorter telomeres have shorter survival times. We aimed to assess whether rare protein-altering variants in genes regulating telomere length are enriched in patients with IPF homozygous for the non-risk alleles at rs35705950.Between Nov 1, 2014, and Nov 1, 2016, we assessed blood samples from patients aged 40 years or older and of European ancestry with sporadic IPF from three international phase 3 clinical trials (INSPIRE, CAPACITY, ASCEND), one phase 2 study (RIFF), and US-based observational studies (Vanderbilt Clinical Interstitial Lung Disease Registry and the UCSF Interstitial Lung Disease Clinic registry cohorts) at the Broad Institute (Cambridge, MA, USA) and Human Longevity (San Diego, CA, USA). We also assessed blood samples from non-IPF controls in several clinical trials. We did whole-genome sequencing to assess telomere length and identify rare protein-altering variants, stratified by rs35705950 genotype. We also assessed rare functional variation in TERT exons and compared telomere length and disease progression across genotypes.We assessed samples from 1510 patients with IPF and 1874 non-IPF controls. 30 (3%) of 1046 patients with an rs35705950 risk allele had a rare protein-altering variant in TERT compared with 34 (7%) of 464 non-risk allele carriers (odds ratio 0·40 [95% CI 0·24–0·66], p=0·00039). Subsequent analyses identified enrichment of rare protein-altering variants in PARN and RTEL1, and rare variation in TERC in patients with IPF compared with controls. We expanded our study population to provide a more accurate estimation of rare variant frequency in these four loci, and to calculate telomere length. The proportion of patients with at least one rare variant in TERT, PARN, TERC, or RTEL1 was higher in patients with IPF than in controls (149 [9%] of 1739 patients vs 205 [2%] of 8645 controls, p=2·44 × 10−8). Patients with IPF who had a variant in any of the four identified telomerase component genes had telomeres that were 3·69–16·10% shorter than patients without a variant in any of the four genes and had an earlier mean age of disease onset than patients without one or more variants (65·1 years [SD 7·8] vs 67·1 years [7·9], p=0·004). In the placebo arms of clinical trials, shorter telomeres were significantly associated with faster disease progression (1·7% predicted forced vital capacity per kb per year, p=0·002). Pirfenidone had treatment benefit regardless of telomere length (p=4·24 × 10−8 for telomere length lower than the median, p=0·0044 for telomere length greater than the median).Rare protein-altering variants in TERT, PARN, TERC, and RTEL1 are enriched in patients with IPF compared with controls, and, in the case of TERT, particularly in individuals without a risk allele at the rs35705950 locus. This suggests that multiple genetic factors contribute to sporadic IPF, which might implicate distinct mechanisms of pathogenesis and disease progression.Genentech, National Institutes of Health, Francis Family Foundation, Pulmonary Fibrosis Foundation, Nina Ireland Program for Lung Health, US Department of Veterans Affairs.