Using an intensive longitudinal design, this study investigated the predictive role of and interaction between competence beliefs and task value in relation to four achievement emotions (enthusiasm, excitement, anxiety, and irritation) as well as cognitive engagement. Data were collected using an experience sampling method to capture the momentary experiences of 81 university students over 14 days. Using a multilevel modeling approach, the study disentangled variations between and within individuals across learning situations. The results indicated that associations between competence and value beliefs and emotions were primarily observed at the situational level. Both competence and value beliefs played important roles in predicting cognitive engagement. In addition, high competence beliefs acted as a buffer, mitigating the positive association between opportunity cost and anxiety and reducing the negative impact of low intrinsic value on irritation. Positive value beliefs emerged as instrumental in fostering cognitive engagement, particularly in situations characterized by limited competence beliefs. Educational relevance statementThe motivation and engagement displayed by university students in diverse learning events offer valuable insights into their dedication and academic involvement in pursuing their degrees. This study highlights the importance of perceiving both high competence beliefs and intrinsic value, which results in stronger associations with enthusiasm and excitement during learning. Conversely, high opportunity cost is linked to greater anxiety, but high competence beliefs act as a protective factor, mitigating this effect. High competence beliefs also counteract the negative impact of low intrinsic value on irritation. Value beliefs, particularly importance and intrinsic value, have a compensatory effect on cognitive engagement. Positive value beliefs play a crucial role in driving cognitive engagement, especially when competence beliefs are lacking. Gaining insight into changes within individuals and variations between students enables educators to effectively tailor instructional strategies and provide support, which in turn fosters students' motivation and engagement.