To investigate the association between infections and disability worsening in people with multiple sclerosis (MS) treated with either B-cell depleting therapy (rituximab) or interferon-beta/glatiramer acetate (IFN/GA). This cohort study spanned from 2000 to 2021, using data from the Swedish MS Registry linked to national health care registries, comprising 8,759 rituximab and 7,561 IFN/GA treatment episodes. The risk of hospital-treated infection was estimated using multivariable Cox models. The association between infections and increase in Expanded Disability Status Scale (EDSS) scores was assessed using a doubly robust generalized estimating equations model. Additionally, a piece-wise exponential model analyzed events of increased disability beyond defined cut-off values, controlling for relapses, and MRI activity. Compared with IFN/GA, rituximab displayed increased risk of both inpatient- and outpatient-treated infections (hazard ratio [HR], 2.08; 95% confidence interval [CI], 1.50-2.90 and HR, 1.37; 95% CI, 1.13-1.67, respectively). An inpatient-treated infection was associated with a 0.19-unit increase in EDSS (95% CI, 0.12-0.26). Degree of worsening was greatest for progressive MS, and under IFN/GA treatment, which unlike rituximab, was more commonly associated with MRI activity. After controlling for relapses and MRI activity, inpatient-treated infections were associated with disability worsening in people with relapsing-remitting MS treated with IFN/GA (HR, 2.01; 95% CI, 1.59-2.53), but not in those treated with rituximab. Compared to IFN/GA, rituximab doubled the infection risk, but reduced the risk of subsequent disability worsening. Further, the risk of worsening after hospital-treated infection was greater with progressive MS than with relapsing-remitting MS. Infection risk should be considered to improve long term outcomes. ANN NEUROL 2024.