Individuals are able to adjust their readiness to shift spatial attention, referred to as “attentional flexibility,” according to the changing demands of the environment, but the neural mechanisms underlying learned adjustments in flexibility are unknown. In the current study, we used fMRI to identify the brain structures responsible for learning shift likelihood. Participants were cued to covertly hold or shift attention among continuous streams of alphanumeric characters and to indicate the parity of target stimuli. Unbeknown to the participants, the stream locations were predictive of the likelihood of having to shift (or hold) attention. Participants adapted their attentional flexibility according to contextual demands, such that the RT cost associated with shifting attention was smallest when shift cues were most likely. Learning model-derived shift prediction error scaled positively with activity within dorsal and ventral frontoparietal regions, documenting that these regions track and update shift likelihood. A complementary inverted encoding model analysis revealed that the pretrial difference in attentional selection strength between to-be-attended and to-be-ignored locations did not change with increasing shift likelihood. The behavioral improvement associated with learned flexibility may primarily arise from a speeding of the shift process rather than from preparatory broadening of attentional selection.