Adherence to healthy dietary patterns is associated with a reduced risk of kidney dysfunction. Nevertheless, the age-related mechanisms that underpin the relationship between diet and kidney function remain undetermined. This study aimed to investigate the mediating role of serum α-Klotho, an anti-aging protein, in the link between a healthy diet and kidney function. A cross-sectional study was conducted on a cohort of 12,817 individuals aged between 40 and 79 years who participated in the National Health and Nutrition Examination Survey (NHANES) from 2007 to 2016. For each participant, the Healthy Eating Index 2015 (HEI-2015) score was calculated as a measure of a healthy dietary pattern. Creatinine-based estimated glomerular filtration rate (eGFR) was used to assess kidney function. Multivariable regression models were used to analyze the association between the standardized HEI-2015 score and eGFR after adjusting for potential confounders. Causal mediation analysis was performed to assess whether serum α-Klotho influenced this association. The mean (±SD) eGFR of all individuals was 86.8 ± 19.8 mL/min per 1.73 m2. A high standardized HEI-2015 score was associated with a high eGFR (β [95% CI], 0.94 [0.64–1.23];p< 0.001). The mediation analysis revealed that serum α-Klotho accounted for 5.6–10.5% of the association of standardized overall HEI-2015 score, total fruits, whole fruits, greens and beans, and whole grain with eGFR in the NHANES. According to the results from the subgroup analysis, serum α-Klotho exerted a mediating effect in the participants aged 60–79 years and in males. A healthy diet may promote kidney function by up-regulating serum anti-aging α-Klotho. This novel pathway suggests important implications for dietary recommendations and kidney health.