This study explores whether DNA methylation (DNAm) mediates the association between lean body mass (LBM) and cognition, as well as whether LBM mediates the association between DNAm and cognition. Based on the data of 59 monozygotic twin pairs, mediation analyses were performed using causal inference test method and mediation analyses. Average causal mediation effect (ACME), average direct effect (ADE), and total effect (TE) were calculated. Among the CpGs associated with LBM, five located within PDGFRB and RP11 genes (ACME: −0.0972−0.0463, |ACME/ADE|: 10.44%−18.30%) negatively mediated the association between LBM and cognition, while one in the PAX2 gene (ACME: 0.3510, |ACME/TE|: 11.84%) positively mediated the association. Besides, the methylation risk score (MRS) of RP11 gene (ACME: −0.0517, |ACME/ADE|: 10.64%) and MRS of all CpGs (ACME: −0.0511, |ACME/ADE|: 10.53%) negatively mediated the association of LBM with cognition. For another, LBM negatively mediated the association between the DNAm level of one CpG within UBXN6 and cognition (ACME: −0.0732, |ACME/TE|: 20.78%), while positively mediated the association between the DNAm level of four CpGs within FOXI2 and cognition (ACME: 0.2812−0.4496, |ACME/TE|: 18.15%−27.29%). It was found the DNAm in PDGFRB, RP11 and PAX2 partially mediates the association between LBM and cognition, and the association between DNAm in UBXN6 and FOXI2 with cognition is also partially mediated by LBM.