Considered as a key component of human capital, mental health has drawn substantial scholarly attention for its effect on people’s health status and economic outcome. When facing the challenge of stress, people’s heterogeneity in cognitive ability and non-cognitive ability causes difference in patterns of coping, resulting in different manifestations in mental health. Previous researches have shown that cognitive and non-cognitive abilities have positively direct or indirect effects on mental health, but few studies research their role of coping with air pollution. We used the China Family Panel Survey (CFPS) and matched individual data with county or district level PM2.5 information from NASA. The study found that air pollution has negative effect on mental health with every increase of 1μg/m3 in PM2.5 deteriorating mental health by 0.038 standard deviation, which is the total effect of air pollution. However, the direct effect of air pollution on mental health will decrease to 0.028 in absolute value when considering mediating effects. By employing different approaches, we found positive mediating effects via cognitive ability and non-cognitive ability. Individuals with high cognitive and non-cognitive abilities are able to accurately diagnose problems and select the optimal coping strategies, thus restoring positive mental health.