Sleep is a state of the brain characterized by a low level of vigilance and diminished consciousness. The reaction to external stimuli and the processing of stimuli are attenuated in sleep. During sleep, the reticular thalamic nucleus inhibits at the thalamus the flow of sensory activity from the senses to the cerebral cortex. After arrival at the afferent layer of the primary cortex, the reduced sensory flow is analyzed and personalized by layers of the cortical area and transferred by the corticofugal system back to appropriate subdivisions of the thalamus. Thalamic subdivisions target the information of the senses to related areas of the cerebral cortex, where the messages can be (sub)consciously perceived. When necessary, the sleeper can be awakened by a wake-up call, either by stimuli indicating danger or by personally meaningful stimuli. Evidently, sensory gating in sleep has two main features. First, it is favorable for sleep, by reducing the cerebral brain activity through the reticular thalamic nucleus, and second, it is necessary for the sleepers' safety and well-being, by analyzing the preserved activity on essential or dangerous external elements by the corticofugal system. These two features are analyzed in detail in non-REM sleep as well as in REM sleep. In the latter type of sleep, the process of sensory gating is almost similar to non-REM sleep, despite the enigmatic reconstruction of external stimuli into the dream. With the extended corticofugal system, sleep phenomena as the first-night effect, the occurrence of local sleep and wake states, as well as the unihemispheric sleep are comprehensible.