The primary somatosensory cortex (S1) is a hub for body sensation of both innocuous and noxious signals, yet its role in somatosensation versus pain is debated. Despite known contributions of S1 to sensory gain modulation, its causal involvement in subjective sensory experiences remains elusive. Here, in mouse S1, we reveal the involvement of cortical output neurons in layers 5 (L5) and 6 (L6) in the perception of innocuous and noxious somatosensory signals. We find that L6 activation can drive aversive hypersensitivity and spontaneous nocifensive behavior. Linking behavior to neuronal mechanisms, we find that L6 enhances thalamic somatosensory responses, and in parallel, strongly suppresses L5 neurons. Directly suppressing L5 reproduced the pronociceptive phenotype induced by L6 activation, suggesting an anti-nociceptive function for L5 output. Indeed, L5 activation reduced sensory sensitivity and reversed inflammatory allodynia. Together, these findings reveal a layer-specific and bidirectional role for S1 in modulating subjective sensory experiences.