BackgroundAnxiety is a prevalent condition with a substantial associated burden of morbidity. Previous literature investigating effects of anxiety on mortality rates has found conflicting results. This is in part due to inadequate consideration of comorbid depression as a confounder and analysing sub-types of anxiety together. The objective of this study was to compare mortality risks in people diagnosed with anxiety.MethodsWe undertook a retrospective cohort study using the ‘The Health Improvement Network’ database (a UK primary care dataset) between 1st January 2005 to 1st January 2018. 345 903 patients with anxiety (exposed group) were matched to 691 449 unexposed patients. Cox regression analyses were used to adjusted hazard ratios (HRs) for mortality risk.ResultsDuring the study period 18 962 patients (5·5%) died in the exposed group compared to 32 288 (4·7%) in the unexposed group. This translated into a crude HR for all of 1·14 (95% CI 1·12 − 1·16), which remained significant after adjustment for key co-variates (including depression) giving a final HR of 1·05 (95% CI 1·03 − 1·07). When broken down by sub-type of anxiety (10·3% (35, 581) had phobias, 82·7% (385,882) has ‘other’ types, and 7·0% (24,262) had stress related anxiety) there were markedly different effect sizes. The adjusted model for the stress-related anxiety sub-type demonstrated a HR of 0·88 (95% CI 0·80 − 0·97). Conversely, the HR was increased in ‘other’ sub-types to 1·07 (95% CI 1·05 − 1·09) and non-significant in phobia types of anxiety.ConclusionA complex relationship is found between anxiety and mortality. The presence of anxiety slightly increased the risk of death, but this risk varies depending on the type of anxiety diagnosed.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12888-023-04877-8.