Pain spontaneously activates adaptive and dynamic learning processes affecting the anticipation of, and the responses to, future pain. Computational models of associative learning effectively capture the production and ongoing changes in conditioned anticipatory responses (eg, skin conductance response), but the impact of this dynamic process on unconditional pain responses remains poorly understood. Here, we investigated the dynamic modulation of pain and the nociceptive flexion reflex by fear learning in healthy human adult participants undergoing a classical conditioning procedure involving an acquisition, reversal and extinction phase. Conditioned visual stimuli (CS+) coterminated with a noxious transcutaneous stimulation applied to the sural nerve on 50% of trials (unconditioned stimuli). Expected pain probabilities and cue associability were estimated using computational modeling by fitting a hybrid learning model to skin conductance response elicited by the CS+. Multilevel linear regression analyses confirmed that trial-by-trial changes in expected pain and associability positively predict ongoing fluctuations in pain outcomes. Mediation analysis further demonstrated that both expected probability and associability affect pain perception through a direct effect and an indirect effect mediated by descending modulatory mechanisms affecting spinal nociceptive activity. Moderation analyses further showed that hyperalgesic effects of associability were larger in individuals reporting more harm vigilance and less emotional detachment. Higher harm vigilance was also associated with a stronger mediation of hyperalgesic effects by spinal processes. These results demonstrate how dynamic changes in pain can be explained by associative learning theory and that resilient attitudes towards fear/pain can attenuate the adverse impact of adaptive aversive learning processes on pain.