Lack of sleep has been found to be associated with cognitive impairment in children, yet the neural mechanism underlying this relationship remains poorly understood. To address this issue, this study utilized the data from the Adolescent Brain Cognitive Development (ABCD) study (n = 4930, aged 9-10), involving their sleep assessments, cognitive measures, and functional magnetic resonance imaging (fMRI) during an emotional n-back task. Using partial correlations analysis, we found that the out-of-scanner cognitive performance was positively correlated with sleep duration. Additionally, the activation of regions of interest (ROIs) in frontal and parietal cortices for the 2-back versus 0-back contrast was positively correlated with both sleep duration and cognitive performance. Mediation analysis revealed that this activation significantly mediated the relationship between sleep duration and cognitive function at both individual ROI level and network level. After performing analyses separately for different sexes, it was revealed that the mediation effect of the task-related activation was present in girls (n = 2546). These findings suggest that short sleep duration may lead to deficit in cognitive function of children, particularly in girls, through the modulation of frontoparietal activation during working memory load.