Rapid eye movement (REM) sleep consists of a dreaming state in which there is activation of the cortical and hippocampal electroencephalogram (EEG), rapid eye movements, and loss of muscle tone. Although REM sleep was discovered more than 50 years ago, the neuronal circuits responsible for switching between REM and non-REM (NREM) sleep remain poorly understood. Here we propose a brainstem flip-flop switch, consisting of mutually inhibitory REM-off and REM-on areas in the mesopontine tegmentum. Each side contains GABA (gamma-aminobutyric acid)-ergic neurons that heavily innervate the other. The REM-on area also contains two populations of glutamatergic neurons. One set projects to the basal forebrain and regulates EEG components of REM sleep, whereas the other projects to the medulla and spinal cord and regulates atonia during REM sleep. The mutually inhibitory interactions of the REM-on and REM-off areas may form a flip-flop switch that sharpens state transitions and makes them vulnerable to sudden, unwanted transitions-for example, in narcolepsy.