Pain emerges from the integration of sensory information about threats and contextual information such as an individual's expectations. However, how sensory and contextual effects on pain are served by the brain is not fully understood so far. To address this question, we applied brief painful stimuli to 40 healthy human participants and independently varied stimulus intensity and expectations. Concurrently, we recorded electroencephalography. We assessed local oscillatory brain activity and interregional functional connectivity in a network of six brain regions playing key roles in the processing of pain. We found that sensory information predominantly influenced local brain oscillations. In contrast, expectations exclusively influenced interregional connectivity. Specifically, expectations altered connectivity at alpha (8 to 12 hertz) frequencies from prefrontal to somatosensory cortex. Moreover, discrepancies between sensory information and expectations, i.e., prediction errors, influenced connectivity at gamma (60 to 100 hertz) frequencies. These findings reveal how fundamentally different brain mechanisms serve sensory and contextual effects on pain.