Both the structure and the amount of sleep are important for brain function. Entry into deep, restorative stages of sleep is time dependent; short sleep bouts selectively eliminate these states. Fragmentation-induced cognitive dysfunction is a feature of many common human sleep pathologies. Whether sleep structure is normally regulated independent of the amount of sleep is unknown. Here, we show that in Drosophila melanogaster, activation of a subset of serotonergic neurons fragments sleep without major changes in the total amount of sleep, dramatically reducing long episodes that may correspond to deep sleep states. Disruption of sleep structure results in learning deficits that can be rescued by pharmacologically or genetically consolidating sleep. We identify two reciprocally connected sets of ellipsoid body neurons that form the heart of a serotonin-modulated circuit that controls sleep architecture. Taken together, these findings define a circuit essential for controlling the structure of sleep independent of its amount.