Background: Interstitial lung disease is a known complication of rheumatoid arthritis, with a lifetime risk of developing the disease in any individual of 7·7%. We aimed to assess the safety, tolerability, and efficacy of pirfenidone for the treatment of patients with rheumatoid arthritis-associated interstitial lung disease (RA-ILD). Methods: TRAIL1 was a randomised, double-blind, placebo-controlled, phase 2 trial done in 34 academic centres specialising in interstitial lung disease in four countries (the UK, the USA, Australia, and Canada). Adults aged 18–85 years were eligible for inclusion if they met the 2010 American College of Rheumatology and European Alliance of Associations for Rheumatology criteria for rheumatoid arthritis and had interstitial lung disease on a high-resolution CT scan imaging and, when available, lung biopsy. Exclusion criteria include smoking, clinical history of other known causes of interstitial lung disease, and coexistant clinically significant COPD or asthma. Patients were randomly assigned (1:1) to receive 2403 mg oral pirfenidone (pirfenidone group) or placebo (placebo group) daily. The primary endpoint was the incidence of the composite endpoint of a decline from baseline in percent predicted forced vital capacity (FVC%) of 10% or more or death during the 52-week treatment period assessed in the intention-to-treat population. Key secondary endpoints included change in absolute and FVC% over 52 weeks, the proportion of patients with a decline in FVC% of 10% or more, and the frequency of progression as defined by Outcome Measures in Rheumatoid Arthritis Clinical Trials (OMERACT) in the intention-to-treat population. This study is registered with ClinicalTrials.gov, NCT02808871. Findings: From May 15, 2017, to March 31, 2020, 231 patients were assessed for inclusion, of whom 123 patients were randomly assigned (63 [51%] to the pirfenidone group and 60 [49%] to the placebo group). The trial was stopped early (March 31, 2020) due to slow recruitment and the COVID-19 pandemic. The difference in the proportion of patients who met the composite primary endpoint (decline in FVC% from baseline of 10% or more or death) between the two groups was not significant (seven [11%] of 63 patients in the pirfenidone group vs nine [15%] of 60 patients in the placebo group; OR 0·67 [95% CI 0·22 to 2·03]; p=0·48). Compared with the placebo group, patients in the pirfenidone group had a slower rate of decline in lung function, measured by estimated annual change in absolute FVC (–66 vs –146; p=0·0082) and FVC% (–1·02 vs –3·21; p=0·0028). The groups were similar with regards to the decline in FVC% by 10% or more (five [8%] participants in the pirfenidone group vs seven [12%] in the placebo group; OR 0·52 [95% CI 0·14–1·90]; p=0·32) and the frequency of progression as defined by OMERACT (16 [25%] in the pirfenidone group vs 19 [32%] in the placebo group; OR 0·68 [0·30–1·54]; p=0·35). There was no significant difference in the rate of treatment-emergent serious adverse events between the two groups, and there were no treatment-related deaths. Interpretation: Due to early termination of the study and underpowering, the results should be interpreted with caution. Despite not meeting the composite primary endpoint, pirfenidone slowed the rate of decline of FVC over time in patients with RA-ILD. Safety in patients with RA-ILD was similar to that seen in other pirfenidone trials. Funding: Genentech.