This study delves into the pivotal integration of Artificial Intelligence (AI) in primary mathematics education, examining the nuanced interplay between teachers’ attitudes toward AI, Contextual Factors (CFs), such as institutional support and resource availability, and their Intention to Use AI (IUAI) in teaching practices. With the advent of digital transformation in education, understanding the dynamics of AI adoption in primary settings becomes increasingly critical. Surveying 476 primary mathematics teachers in China, this research employs partial least squares structural equation modeling (PLS-SEM) to unravel the complexities influencing AI integration. The findings reveal that teachers’ attitudes significantly impact their IUAI, while CF, particularly institutional support and resource availability, play a crucial role in shaping these attitudes and directly influencing IUAI. This investigation not only bridges a vital research gap by offering empirical insights into the determinants of AI adoption in a primary education context but also provides a robust framework for educators, policymakers, and stakeholders to foster a conducive environment for AI integration. By aligning AI deployment with pedagogical strategies, this study contributes significantly to enhancing the quality and effectiveness of mathematics education, underscoring the transformative potential of AI in shaping future educational landscapes.