In the context of a rapidly aging population, research on elderly labor supply and cognitive function holds significant policy relevance. Using panel data from the 2018 and 2020 waves of the China Health and Retirement Longitudinal Study(CHARLS), this article empirically examines the impact of elderly labor participation on cognitive function. The findings show that elderly labor participation has a significant positive effect on cognitive function. Both agricultural and non-agricultural labor participation help delay cognitive decline, with no significant difference observed between the two types. The beneficial effects operate through two primary mechanisms: physical health and mental health. Specifically, agricultural labor helps improve physical health, thereby slowing cognitive decline, while non-agricultural labor mainly enhances psychological well-being, which in turn contributes to better cognitive performance. Moreover, the positive impact of labor participation is more pronounced among individuals aged 70 and above, those lacking social engagement, and elderly men. Based on these findings, the article recommends actively developing elderly human resources, encouraging moderate physical activity, improving the mental health service system for older adults, and promoting social participation among the elderly.