We sought to report the effectiveness of infliximab and adalimumab over the first 3 years of treatment and to define the factors that predict anti-TNF treatment failure and the strategies that prevent or mitigate loss of response. Personalised Anti-TNF therapy in Crohn's disease (PANTS) is a UK-wide, multicentre, prospective observational cohort study reporting the rates of effectiveness of infliximab and adalimumab in anti-TNF-naive patients with active luminal Crohn's disease aged 6 years and older. At the end of the first year, sites were invited to enrol participants still receiving study drug into the 2-year PANTS-extension study. We estimated rates of remission across the whole cohort at the end of years 1, 2, and 3 of the study using a modified survival technique with permutation testing. Multivariable regression and survival analyses were used to identify factors associated with loss of response in patients who had initially responded to anti-TNF therapy and with immunogenicity. Loss of response was defined in patients who initially responded to anti-TNF therapy at the end of induction and who subsequently developed symptomatic activity that warranted an escalation of steroid, immunomodulatory, or anti-TNF therapy, resectional surgery, or exit from study due to treatment failure. This study was registered with ClinicalTrials.gov, NCT03088449, and is now complete. Between March 19, 2014, and Sept 21, 2017, 389 (41%) of 955 patients treated with infliximab and 209 (32%) of 655 treated with adalimumab in the PANTS study entered the PANTS-extension study (median age 32·5 years [IQR 22·1-46·8], 307 [51%] of 598 were female, and 291 [49%] were male). The estimated proportion of patients in remission at the end of years 1, 2, and 3 were, for infliximab 40·2% (95% CI 36·7-43·7), 34·4% (29·9-39·0), and 34·7% (29·8-39·5), and for adalimumab 35·9% (95% CI 31·2-40·5), 32·9% (26·8-39·2), and 28·9% (21·9-36·3), respectively. Optimal drug concentrations at week 14 to predict remission at any later timepoints were 6·1-10·0 mg/L for infliximab and 10·1-12·0 mg/L for adalimumab. After excluding patients who had primary non-response, the estimated proportions of patients who had loss of response by years 1, 2, and 3 were, for infliximab 34·4% (95% CI 30·4-38·2), 54·5% (49·4-59·0), and 60·0% (54·1-65·2), and for adalimumab 32·1% (26·7-37·1), 47·2% (40·2-53·4), and 68·4% (50·9-79·7), respectively. In multivariable analysis, loss of response at year 2 and 3 for patients treated with infliximab and adalimumab was predicted by low anti-TNF drug concentrations at week 14 (infliximab: hazard ratio [HR] for each ten-fold increase in drug concentration 0·45 [95% CI 0·30-0·67], adalimumab: 0·39 [0·22-0·70]). For patients treated with infliximab, loss of response was also associated with female sex (vs male sex; HR 1·47 [95% CI 1·11-1·95]), obesity (vs not obese 1·62 [1·08-2·42]), baseline white cell count (1·06 [1·02-1·11) per 1 × 109 increase in cells per L), and thiopurine dose quartile. Among patients treated with adalimumab, carriage of the HLA-DQA1*05 risk variant was associated with loss of response (HR 1·95 [95% CI 1·17-3·25]). By the end of year 3, the estimated proportion of patients who developed anti-drug antibodies associated with undetectable drug concentrations was 44·0% (95% CI 38·1-49·4) among patients treated with infliximab and 20·3% (13·8-26·2) among those treated with adalimumab. The development of anti-drug antibodies associated with undetectable drug concentrations was significantly associated with treatment without concomitant immunomodulator use for both groups (HR for immunomodulator use: infliximab 0·40 [95% CI 0·31-0·52], adalimumab 0·42 [95% CI 0·24-0·75]), and with carriage of HLA-DQA1*05 risk variant for infliximab (HR for carriage of risk variant: infliximab 1·46 [1·13-1·88]) but not for adalimumab (HR 1·60 [0·92-2·77]). Concomitant use of an immunomodulator before or on the day of starting infliximab was associated with increased time without the development of anti-drug antibodies associated with undetectable drug concentrations compared with use of infliximab alone (HR 2·87 [95% CI 2·20-3·74]) or introduction of an immunomodulator after anti-TNF initiation (1·70 [1·11-2·59]). In years 2 and 3, 16 (4%) of 389 patients treated with infliximab and 11 (5%) of 209 treated with adalimumab had adverse events leading to treatment withdrawal. Nine (2%) patients treated with infliximab and two (1%) of those treated with adalimumab had serious infections in years 2 and 3. Only around a third of patients with active luminal Crohn's disease treated with an anti-TNF drug were in remission at the end of 3 years of treatment. Low drug concentrations at the end of the induction period predict loss of response by year 3 of treatment, suggesting higher drug concentrations during the first year of treatment, particularly during induction, might lead to better long-term outcomes. Anti-drug antibodies associated with undetectable drug concentrations of infliximab, but not adalimumab, can be predicted by carriage of HLA-DQA1*05 and mitigated by concomitant immunomodulator use for both drugs. Guts UK, Crohn's and Colitis UK, Cure Crohn's Colitis, AbbVie, Merck Sharp and Dohme, Napp Pharmaceuticals, Pfizer, and Celltrion Healthcare.