The attentional bias literature has consistently failed to take context into account. We developed a novel paradigm in immersive virtual reality (VR) with pain stimuli where it would be adaptive or nonadaptive to attend to the stimuli. Participants had to indicate the location of the stimuli. Seventy participants were recruited. The VR-attention task assessed overall attentional bias (the tendency to prioritize pain compared with nonpain stimuli) and attentional alignment (the tendency to attend to pain more in adaptive than nonadaptive situations). Pain tolerance and threshold were measured using electrocutaneous stimulation and thermal pain. We conducted 2 (context: adaptive vs nonadaptive) × 2 (congruence: congruent vs incongruent) Analysis of Covariance, controlling for threat. Participants responded to pain probes more quickly in adaptive than nonadaptive contexts. There was an overall bias away from pain-related stimuli (avoidance) in reaction time to the target. There was also an interaction where avoidance was greater in nonadaptive contexts, indicative of attentional alignment. For gaze behavior, both attentional alignment and attentional bias were observed for latency to first fixation on the target, such that participants showed vigilance for pain particularly in the adaptive context. Attentional alignment was correlated with threshold and tolerance from electrocutaneous stimulation but not thermal pain. In conclusion, we found overall attentional biases indicating vigilance (latency to first fixation) and avoidance (response to target). We also found that participants evidenced a pattern of attention favoring adaptive over nonadaptive contexts (attentional alignment). It was attentional alignment, but not overall attentional bias, that predicted pain tolerance and threshold. PerspectiveThe study explored attentional processes in pain through a novel paradigm designed in VR. The results found that positive attentional alignment, or the tendency to attend to pain more in adaptive contexts rather than nonadaptive contexts, predicted pain outcomes.