Our study’s mediation analysis suggests that although BDNF is a biomarker influenced by T2DM and cognition, it does not mediate the relationship between cognitive impairment and diabetes. This evidence concerns the gene BDNF and diabetes mellitus.