Summary: This longitudinal study analyzes whether selected components of executive function (EF) measured during the preschool period predict several indices of math achievement in primary school. Six EF measures were assessed in a sample of 5-year-old children ($N=175$). The math achievement of the same children was then tested in Grades 1 and 3 using both a composite math score and three single indices of written calculation, arithmetical facts, and problem solving. Using previous results obtained from the same sample of children, a confirmatory factor analysis examining the latent EF structure in kindergarten indicated that a two-factor model provided the best fit for the data. In this model, inhibition and working memory (WM)-flexibility were separate dimensions. A full structural equation model was then used to test the hypothesis that math achievement (the composite math score and single math scores) in Grades 1 and 3 could be explained by the two EF components comprising the kindergarten model. The results indicate that the WM-flexibility component measured during the preschool period substantially predicts mathematical achievement, especially in Grade 3. The math composite scores were predicted by the WM-flexibility factor at both grade levels. In Grade 3, both problem solving and arithmetical facts were predicted by the WM-flexibility component. The results empirically support interventions that target EF as an important component of early childhood mathematics education.