Rapid eye movement (REM) sleep is associated with the consolidation of emotional memories. Yet, the underlying neocortical circuits and synaptic mechanisms remain unclear. We found that REM sleep is associated with a somatodendritic decoupling in pyramidal neurons of the prefrontal cortex. This decoupling reflects a shift of inhibitory balance between parvalbumin neuron-mediated somatic inhibition and vasoactive intestinal peptide-mediated dendritic disinhibition, mostly driven by neurons from the central medial thalamus. REM-specific optogenetic suppression of dendritic activity led to a loss of danger-versus-safety discrimination during associative learning and a lack of synaptic plasticity, whereas optogenetic release of somatic inhibition resulted in enhanced discrimination and synaptic potentiation. Somatodendritic decoupling during REM sleep promotes opposite synaptic plasticity mechanisms that optimize emotional responses to future behavioral stressors.