Slow waves represent one of the prominent EEG signatures of non-rapid eye movement (non-REM) sleep and are thought to play an important role in the cellular and network plasticity that occurs during this behavioral state. These slow waves of natural sleep are currently considered to be exclusively generated by intrinsic and synaptic mechanisms within neocortical territories, although a role for the thalamus in this key physiological rhythm has been suggested but never demonstrated. Combining neuronal ensemble recordings, microdialysis, and optogenetics, here we show that the block of the thalamic output to the neocortex markedly (up to 50%) decreases the frequency of slow waves recorded during non-REM sleep in freely moving, naturally sleeping-waking rats. A smaller volume of thalamic inactivation than during sleep is required for observing similar effects on EEG slow waves recorded during anesthesia, a condition in which both bursts and single action potentials of thalamocortical neurons are almost exclusively dependent on T-type calcium channels. Thalamic inactivation more strongly reduces spindles than slow waves during both anesthesia and natural sleep. Moreover, selective excitation of thalamocortical neurons strongly entrains EEG slow waves in a narrow frequency band (0.75-1.5 Hz) only when thalamic T-type calcium channels are functionally active. These results demonstrate that the thalamus finely tunes the frequency of slow waves during non-REM sleep and anesthesia, and thus provide the first conclusive evidence that a dynamic interplay of the neocortical and thalamic oscillators of slow waves is required for the full expression of this key physiological EEG rhythm.