ObjectivesTo investigate the association between metabolic syndrome (MetS) and anxiety and to explore the mediating role of inflammation indicators in this relationship based on the UK Biobank prospective cohort. MethodsThis population-based retrospective cohort study analyzed data from 308,352 participants. MetS was defined according to criteria jointly developed by the American Heart Association, the National Heart, Lung, and Blood Institute, and the International Diabetes Federation. Anxiety was defined using ICD-10 codes. Cox proportional risk regression models were used to explore the hazard ratios (HRs) between MetS, components of MetS, number of MetS components, and anxiety. The mediating effect of inflammation on the association between MetS and anxiety was explored using longitudinal mediation analysis. ResultsA total of 308,352 participants were included in this study. Of these, 9471 (3.071 %) developed anxiety over a mean follow-up of 12.05 years. In the fully adjusted model, MetS increased the risk of anxiety by 13.6 % (HR: 1.136, 95 %CI: 1.085–1.189). All MetS components significantly increased the risk of anxiety, with HRs ranging from 1.066 to 1.165. When MetS was treated as a linear variable, the risk of anxiety increased by 6.5 % per component increment. Age-stratified results showed that the risk of MetS for anxiety was higher among those <55 years (HR: 1.23, 95 %CI: 1.13–1.33) than among those ≥55 years (HR: 1.12, 95 %CI: 1.06–1.18). The mediating effects of platelets, lymphocytes, neutrophils, C-reactive protein, leukocytes, and INFLA scores on the association between MetS and anxiety were significant, with mediating effects of 2.30 %, 7.20 %, 15.9 %, 20.7 %, 22.0 %, and 25.3 %, respectively, and a combined mediating effect of these inflammatory factors was 30.8 % (except for INFLA scores). ConclusionsMetS and its components significantly increased the risk of anxiety, which increased with the number of components. This association may be partially mediated by serum inflammatory indicators, suggesting that MetS may increase the risk of anxiety by elevating the level of chronic inflammation.