Using the TIMSS 2019 data from fourth (N = 2947) and eighth graders (N = 3265) in Hong Kong, this study investigated the link between individual- and class-level mathematics achievement and students' attitudes towards mathematics (ATM; i.e., self-concept, perceived mathematical value, enjoyment and boredom). Student achievement was positively connected to their ATM, whereas class-level achievement was negatively related. Meanwhile, the connections between individual- and class-level achievement and ATM were more robust in the eighth grade. Besides, cross-level interaction effects indicated that individual performance and gender played moderating roles in the class-level achievement and self-concept/boredom. More specifically, the link between class-level achievement and self-concept was stronger for underachievers in both the fourth and eighth grades, but the connection between class-level achievement and boredom was stronger only for girls and underachievers in the eighth grade.