Objectives To investigate absolute and relative risk of serious infections in adult/elderly inflammatory bowel disease (IBD) diagnosed 2002–2017. Methods Nationwide, register-based cohort study of Swedish patients with IBD compared with general population matched reference individuals with regard to time to first serious infection, equal to hospital admission. Multivariable Cox regression estimated hazard ratios (HRs) for any serious infection. Secondary outcomes included site-specific infections, opportunistic infections and sepsis. Results We identified 47 798 individuals with IBD. During a follow-up of 329 000 person-years, they had 8752 first serious infections (26.6 per 1000 person-years). This compared with an incidence rate of 10.7 per 1000 person-years in matched reference individuals, corresponding to a 2.53-fold increased hazard of serious infections (95%CI = 2.47–2.59). The HR for serious infection in elderly-onset IBD was 2.01 (95%CI = 1.95–2.08). The relative hazard of serious infection was somewhat higher in Crohn’s disease (2.94; 95%CI = 2.81–3.06) than in ulcerative colitis (2.24; 95%CI = 2.17–2.31). The HR for serious infections was high in the first year of follow-up (5.17; 95%CI = 4.93–5.42). Individuals with IBD were at a particularly high relative hazard of gastrointestinal and opportunistic infections. The HR for sepsis was 2.47 (95%CI = 2.32–2.63). The relative rates for serious infections in IBD increased in recent years. Conclusions Patients with adult-onset IBD are at increased risk of serious infections, particularly gastrointestinal and opportunistic infections. Relative rates were highest just after IBD diagnosis, and seem to have increased in recent years.