The essential but enigmatic functions of sleep1,2 must be reflected in molecular changes sensed by the brain's sleep-control systems. In the fruitfly Drosophila, about two dozen sleep-inducing neurons3 with projections to the dorsal fan-shaped body (dFB) adjust their electrical output to sleep need4, via the antagonistic regulation of two potassium conductances: the leak channel Sandman imposes silence during waking, whereas increased A-type currents through Shaker support tonic firing during sleep5. Here we show that oxidative byproducts of mitochondrial electron transport6,7 regulate the activity of dFB neurons through a nicotinamide adenine dinucleotide phosphate (NADPH) cofactor bound to the oxidoreductase domain8,9 of Shaker's KVβ subunit, Hyperkinetic10,11. Sleep loss elevates mitochondrial reactive oxygen species in dFB neurons, which register this rise by converting Hyperkinetic to the NADP+-bound form. The oxidation of the cofactor slows the inactivation of the A-type current and boosts the frequency of action potentials, thereby promoting sleep. Energy metabolism, oxidative stress, and sleep-three processes implicated independently in lifespan, ageing, and degenerative disease6,12-14-are thus mechanistically connected. KVβ substrates8,15,16 or inhibitors that alter the ratio of bound NADPH to NADP+ (and hence the record of sleep debt or waking time) represent prototypes of potential sleep-regulatory drugs.