Metabolic syndrome (MetS) can lead to accelerated brain aging and cognitive decline. Evidence has suggested the involvement of the microbiota-gut-brain axis in the relationship between MetS and cognitive dysfunction, but the underlying mechanisms are unclear. Using magnetic resonance imaging and 16S rRNA gene amplicon sequencing, we collected data of brain structure (gray matter volume and white matter integrity) and gut microbiome from 97 patients with MetS and 103 sex-, age- and education-matched healthy controls. The Trail-making Test A and auditory verbal learning test were used to assess executive function and memory. Group differences in gut microbiome, brain structure, and cognitive function as well as their plausible interactive links in patients with MetS were examined. We found that patients with MetS exhibited impaired executive function and memory ability, both depleted short-chain fatty acids (SCFA)-producing bacteria and enriched inflammation-triggering bacteria, gray matter atrophy of several brain regions and microstructural integrity damage of multiple white matter tracts. Of more importance, correlation and mediation analyses demonstrated that the abnormal brain structure mediated the associations between the depleted anti-inflammatory bacteria (i.e., Clostridium XlVa, Kineothrix and Acetivibrio) and the impaired cognitive function in patients with MetS. Our findings not only point to new hypotheses about potential neurobiological pathways by which gut microbial dysbiosis may lead to cognitive dysfunction in the context of MetS, but also highlight the potential therapeutic value of targeting gut microbiota for cognitive impairments in patients with MetS.