Executive function is an underlying mechanism linking family socioeconomic status (SES) and academic achievement. Previous studies mainly investigated either the mediating or moderating role of executive function within this relationship, which either overlook the individual differences that are independent of the environment or neglect the influence of the environment on shaping personal factors. To avoid a piecemeal approach to theory, the current study aimed to test the mediating and moderating roles of executive function in a single analytic model. Two hundred and thirty-six Chinese fifth graders (Mage = 10.70 years, SD = 0.49, range = 10.23-11.75 years, and 40.30% girls) were recruited. Their executive function performance was measured using eight different tasks, and their Chinese literacy skills and mathematics achievement were assessed by routine school evaluations. One year after the initial assessment, children's academic achievements were evaluated again. Results demonstrated that parental SES positively predicted children's academic achievement when controlling for prior academic achievement, and children's executive function mediated this relationship. Also, executive function moderated the association between SES and academic achievement in that, the negative predictive effect of low SES on academic achievement was only significant for children with lower levels of executive function, which is not shown in children with higher levels of executive function. By demonstrating the dual roles of executive function in the SES-achievement link, this work provides evidence for supporting the optimal development of children from diverse socioeconomic backgrounds and emphasizes the significance of developing individualized intervention strategies on executive function to mitigate the negative effect of low SES on children's academic achievement.