The present study was conducted to investigate the mediating role of achievement anxiety in the relationship between perfectionism and cognitive flexibility in math learning in students. The study was correlational using structural equation modeling. The statistical population included senior high school female students in the academic year of 2022-2023. According to the obvious variables, allocation of 25 coefficients, and taking into account the incomplete questionnaires, 231 students were selected by convenience sampling. The instruments included Hewitt and Flett’s perfectionism (1991) questionnaire, Dennis and Vander Wal's cognitive flexibility (2010) questionnaire, and Alpert and Haber's achievement anxiety (1960) questionnaire. Also, the students’ math scores at the end of the semester were used to measure their math learning. The data were analyzed by Pearson's correlation coefficient test and structural equation modeling using SPSS18 and AMOS24 software. The results showed that perfectionism and achievement anxiety have a negative direct effect, and cognitive flexibility has a positive direct effect on math learning. Also, perfectionism and cognitive flexibility have an indirect effect on math learning through achievement anxiety. The research model was also confirmed and the result showed that the variable measurement models have a good fit and 41% of the math learning variance is explained by the research variables. The findings of this research can be beneficial for teaching and learning of students. With educational planning and helping students, their cognitive capacities and competencies can be increased and their mathematical learning can be effectively improved.