Proper cognitive functions are critical to the life of the elderly. With the rapid aging of the population, community support plays an important role in cognitive functioning. This study examines the association between community support and the level of cognitive functioning in the elderly, and the mediating effect of social participation in the relationship. Based on the panel data of China Longitudinal Healthy Longevity Survey (CLHLS) in 2005, 2008, 2011, 2014, and 2018, people aged 65 and over are selected as the research object (N = 35,479). The panel Logit model is used to analyze the influence of community support on their cognitive functioning. In addition, the stepwise regression and KHB decomposition methods are used to test the influence mechanism of community support on their cognitive function. The benchmark regression results show that there is a significant correlation between community support and cognitive function in the elderly (OR: 1.64, 95% CI: 1.41–1.91, p < 0.01). Daily care (OR: 1.75, 95% CI: 1.33–2.29, p < 0.01) has the strongest impact on the cognitive function of the elderly, followed by health care (OR: 1.70, 95% CI: 1.43–2.01, p < 0.01) and legal support (OR: 1.64, 95% CI: 1.37–1.95, p < 0.01), while psychological care (OR: 1.62, 95% CI: 1.31–2.01, p < 0.01) has the weakest impact on the cognitive function of the elderly. The results of the mediation effect test show that social participation plays a significant intermediary role in the impact of community support on the cognitive function of the elderly (mediation percentage: 16.89%), demonstrating that community support can improve the cognitive function of the elderly by promoting the social participation of the elderly. In classified community support, social participation plays a significant intermediary role in the impact of psychological care on cognition (mediation percentage: 46.10%).