Observational studies have established a connection between body mass index (BMI) and an increased risk of cognitive decline. However, a comprehensive investigation into the causal relationships between BMI and cognitive function across diverse age groups, as well as the genetic underpinnings of this relationship, has been notably lacking. This study aims to investigate causality and the shared genetic underpinnings of between BMI and cognitive function by conducting a thorough genome-wide analysis, thereby provide valuable insights for developing personalized intervention strategies to promote cognitive health. Genetic associations between BMI and cognitive function were thoroughly investigated through covariate genetic analysis and chained imbalance score regression, utilizing data from genome-wide association studies (GWAS). Bi-directional Mendelian Randomization (MR) was employed to uncover associations and potential functional genes were further scrutinized through Cross-trait meta-analysis and Summary-data-based MR (SMR). Subsequently, a detailed examination of the expression profiles of the identified risk SNPs in tissues and cells was conducted. The study found a significant negative correlation between BMI and cognitive function (β = -0.16, P = 1.76E-05), suggesting a causal linkage where higher BMI values were predictive of cognitive impairment. We identified 5 genetic loci (rs6809216, rs7187776, rs11713193, rs13096480, and rs13107325) between BMI and cognitive function by cross-trait meta-analysis and 5 gene-tissue pairs were identified by SMR analysis. Moreover, two novel risk genes TUFM and MST1R were shared by both cross-trait analysis and SMR analysis, which had not been observed in previous studies. Furthermore, significant enrichment of single nucleotide polymorphisms (SNPs) at tissue- and cell-specific levels was identified for both BMI and cognitive function, predominantly within the brain. This study uncovers a causal relationship between BMI and cognitive function, with the discovery of TUFM and MST1R as shared genetic factors associated with both conditions. This novel finding offers new insights into the development of preventative strategies for cognitive decline in obese individuals, and further enhances our understanding of the underlying pathophysiology of these conditions. Furthermore, these findings could serve as a guide for the development of innovative therapeutic approaches to address cognitive decline in obese individuals.