Avoidance behavior is protective, yet in the absence of genuine bodily threat, it may become disabling. Therefore, we investigated whether avoidance generalizes to novel safe contexts based on the similarity with the acquisition context. Healthy participants performed arm movements using a robotic arm to reach a target. Three trajectories (T1-3) led to the target. During acquisition, a painful stimulus could be partly/completely prevented by performing more effortful trajectories (i.e. longer and more force needed), T2/T3, in the pain-avoidance context (e.g. black background); in the yoked context (e.g. white background), the same reinforcement schedule was applied irrespective of the chosen trajectories. Generalization of avoidance was tested in two novel contexts (e.g. shades of grey backgrounds). We assessed self-reported pain-expectancy and pain-related fear for all trajectories, and avoidance behavior (i.e. maximal deviation from T1). Results confirm that fear and expectancy ratings reflect the response-outcome contingencies and differential learning selectively generalized to the novel context resembling the original pain-avoidance context. Furthermore, a linear trend in avoidance behavior across contexts emerged, which is indicative of a generalization gradient. Participants avoided more in the context resembling the original pain-avoidance context than in the one resembling the yoked context, but this effect was not statistically significant. PERSPECTIVE: We demonstrated acquisition of pain-related avoidance behavior in a within-subjects design, showing modulation of pain-related fear and pain-expectancy by context and providing limited evidence that avoidance selectively generalizes to novel, similar contexts. These results provide insight regarding the underlying mechanisms of the spreading of protective behavior in chronic pain patients.