Sleep disconnects animals from the external world, at considerable risks and costs that must be offset by a vital benefit. Insight into this mysterious benefit will come from understanding sleep homeostasis: to monitor sleep need, an internal bookkeeper must track physiological changes that are linked to the core function of sleep. In Drosophila, a crucial component of the machinery for sleep homeostasis is a cluster of neurons innervating the dorsal fan-shaped body (dFB) of the central complex. Artificial activation of these cells induces sleep, whereas reductions in excitability cause insomnia. dFB neurons in sleep-deprived flies tend to be electrically active, with high input resistances and long membrane time constants, while neurons in rested flies tend to be electrically silent. Correlative evidence thus supports the simple view that homeostatic sleep control works by switching sleep-promoting neurons between active and quiescent states. Here we demonstrate state switching by dFB neurons, identify dopamine as a neuromodulator that operates the switch, and delineate the switching mechanism. Arousing dopamine caused transient hyperpolarization of dFB neurons within tens of milliseconds and lasting excitability suppression within minutes. Both effects were transduced by Dop1R2 receptors and mediated by potassium conductances. The switch to electrical silence involved the downregulation of voltage-gated A-type currents carried by Shaker and Shab, and the upregulation of voltage-independent leak currents through a two-pore-domain potassium channel that we term Sandman. Sandman is encoded by the CG8713 gene and translocates to the plasma membrane in response to dopamine. dFB-restricted interference with the expression of Shaker or Sandman decreased or increased sleep, respectively, by slowing the repetitive discharge of dFB neurons in the ON state or blocking their entry into the OFF state. Biophysical changes in a small population of neurons are thus linked to the control of sleep-wake state.