When confronted with challenging schoolwork, some students flourish, whereas others disengage. Why do students respond so differently to difficult classes? In this study, we examined the possibility that Need for Cognition, as the individual tendency to actively seek and enjoy cognitive effort, explains differences in engagement with challenging course content in mathematics classes. We tested this in an experience sampling method study in real-life mathematics classes in which 414 students (Mage = 16.2 years, 238 females), over a period of 10 consecutive school days, repeatedly rated the perceived level of difficulty of the class and five components of their momentary engagement (i.e., enjoyment, interest, concentration, active participation, and boredom). Associations between perceived class difficulty and students’ engagement were investigated both at the between-person and within-person level. Also, we tested whether differences among students in these associations were significantly related to students’ Need for Cognition. First, at both levels, a negative quadratic association (inverse U-shape) between difficulty and engagement was observed, with student engagement being lower when students rated classes as very easy or very difficult. Second, substantial differences in difficulty–engagement associations were observed between students. Third, beyond having a positive main effect on student engagement, students’ Need for Cognition was found to moderate difficulty–engagement associations at both levels, with more positive difficulty–engagement associations among students with high relative to low Need for Cognition. These findings highlight differences between students in how class difficulty is associated with student engagement and underscore the importance of Need for Cognition in understanding these differences. (PsycInfo Database Record (c) 2025 APA, all rights reserved)