Good sleep quality is essential for maintaining the body’s attention during wakefulness, which is easily affected by external factors such as an ambient temperature. However, the mechanism by which an ambient temperature influences sleep–wake behaviors remains unclear. The dorsomedial hypothalamus (DMH) has been reported to be involved in thermoregulation. It also receives projection from the preoptic area, which is an important region for sleep and energy homeostasis and the suprachiasmatic nucleus—a main control area of the clock rhythm. Therefore, we hypothesized that the DMH plays an important role in the regulation of sleep related to ambient temperatures. In this study, we found that cold exposure (24/20/16/12 °C) increased wakefulness and decreased non–rapid eye movement (NREM) sleep, while warm exposure (32/36/40/44 °C) increased NREM sleep and decreased wakefulness compared to 28 °C conditions in wild-type mice. Then, using non-specific and specific apoptosis, we found that lesions of whole DMH neurons and DMH γ–aminobutyric acid (GABA)-ergic neurons induced by caspase-3 virus aggravated the fluctuation of core body temperature after warm exposure and attenuated the change in sleep–wake behaviors during cold and warm exposure. However, chemogenetic activation or inhibition of DMH GABAergic neurons did not affect the sleep–wake cycle. Collectively, our findings reveal an essential role of DMH GABAergic neurons in the regulation of sleep–wake behaviors elicited by a change in ambient temperature.