All-cause mortality was lower than expected following both THA and TKA. However, there was excess mortality due to mental diseases such as dementia following both THA (SMR 1.40, 95% CI 1.08, 1.80) and TKA (SMR 1.49, 95% CI 1.19, 1.85). There was also excess mortality from inflammatory musculoskeletal diseases in THA (SMR 3.50, 95% CI 2.11, 5.46) and TKA (SMR 4.85, 95% CI 3.29, 6.88). When the cohorts were restricted to patients with osteoarthritis as the surgical indication, the excess risk of death from mental diseases still persisted in THA (SMR 1.36, 95% CI 1.02, 1.78) and TKA (SMR 1.52, 95% CI 1.20, 1.91).