Background Conventional therapy of inflammatory bowel disease with traditional immunosuppressant medication is increasingly being replaced by biological agents. However, the response to these biological agents may be lost over time, with discontinuation being a marker of loss of effectiveness. There are few published reports on the treatment drug survival of infliximab and adalimumab in patients with inflammatory bowel disease. Objective This study compared the drug survival of infliximab versus adalimumab as first- and second-line treatments, identified factors associated with drug survival, and described reasons for treatment withdrawal. Setting A pharmacy department of a university hospital in Spain. Method A retrospective single-centre cohort study of all patients with inflammatory bowel disease treated with biological agents between 2008 and 2017 at a regional referral hospital. The primary outcome was drug survival and associated factors during a follow-up of 52 months. Main outcome measure Drug survival of infliximab versus adalimumab. Results One hundred thirty-four patients with inflammatory bowel disease (73.9% Crohn's disease and 26.1% ulcerative colitis) were treated with biological therapy. The overall mean drug survival of first-line treatment with an anti-tumour necrosis factor agent was 18.6 months (SD 14.9), with mean values of 20.2 months (SD 16.6) for adalimumab and 17.1 months (SD 13.1) for infliximab. As a second-line treatment, the drug survival of anti-tumour necrosis factor agents was 17.9 months (SD 15.6), with mean values of 22.9 months (SD 17.1) for adalimumab and 12.5 months (SD 11.7) for infliximab. The difference in time to discontinuation at 52 months of follow-up between the infliximab and adalimumab subgroups, as either first- or second-line treatment, was not statistically significant (p = 0.547 and p = 0.676, respectively). Therapeutic drug monitoring was the only factor associated with greater drug survival in first-line treatment (HR 0.27; 95% confidence interval, CI 0.15-0.50) and second-line treatment (HR 0.26; 95% CI 0.10-0.65). Secondary failure to treatment was the most frequent reason for withdrawal. Conclusion Infliximab and adalimumab showed similar drug survival as first- and second-line anti-tumour necrosis factor treatments. Therapeutic drug monitoring was associated with higher drug survival for both first- and second-line anti-tumour necrosis factor treatments.