In humans, gamma-band oscillations in the primary somatosensory cortex (S1) correlate with subjective pain perception. However, functional contributions to pain and the nature of underlying circuits are unclear. Here we report that gamma oscillations, but not other rhythms, are specifically strengthened independently of any motor component in the S1 cortex of mice during nociception. Moreover, mice with inflammatory pain show elevated resting gamma and alpha activity and increased gamma power in response to sub-threshold stimuli, in association with behavioral nociceptive hypersensitivity. Inducing gamma oscillations via optogenetic activation of parvalbumin-expressing inhibitory interneurons in the S1 cortex enhances nociceptive sensitivity and induces aversive avoidance behavior. Activity mapping identified a network of prefrontal cortical and subcortical centers whilst morphological tracing and pharmacological studies demonstrate the requirement of descending serotonergic facilitatory pathways in these pain-related behaviors. This study thus describes a mechanistic framework for modulation of pain by specific activity patterns in the S1 cortex.