Different interdependent factors have been related to mathematical performance. Among them, general and specific cognitive factors, affective-motivational factors, and contextual factors stand out. This study analyzes the impact of perceived competence and utility value attitudes on mathematical performance and its different components. It also explores the differences in these attitudes between children with low performance (LP), average performance (AP) and high performance (HP). The sample consisted of 91 students (11-12 years old). Mathematical performance and motivational variables were evaluated using the Battery for the Evaluation of Basic Mathematical Competence and the Attitudes Towards Mathematics Inventory, respectively. Differences between groups in motivational variables were analyzed. The data obtained indicate that the motivational variable with the greatest relationship and predictive power is perceived competence. Moreover, from a preventive approach, perceived competence is an aspect to be taken into special consideration, especially in students with RB. The utility value variable makes an additional significant contribution to the explanation of performance. Differences also appear between the LP, AP and HP groups in perceived competence. The study suggests that motivation, has an important responsibility on mathematical performance at the end of the primary stage. In this sense, it is essential to propose relevant and achievable challenges, offering feedback so that students generate beliefs adjusted to their real abilities. Finally, families and teachers should provide positive learning environments, with multiple opportunities for participation and support in order to successfully face mathematical learning in primary education, especially in the last grades.