Like a cleaner sweeping the halls after the lights go out, major changes occur in the brain during sleep to flush out waste and ward off disease, researchers say.
The research in the journal Science offers new answers to explain why people spend a third of their lives asleep and may help in treating dementia and other neurological disorders.
In lab experiments on mice, researchers observed how cellular waste was flushed out via the brain's blood vessels into the body's circulatory system and eventually the liver.
These waste products included amyloid beta, a protein that when accumulated is a driver of Alzheimer's disease.
In order to help remove the waste, cerebral spinal fluid is pumped through brain tissue.
The process is sped along during sleep because the brain's cells shrink by about 60 per cent, allowing the fluid to move faster and more freely through the brain.
The whole operation takes place in what researchers call the glymphatic system, which appears to be nearly 10 times more active during sleep than while awake.
"The brain only has limited energy at its disposal," said lead author Maiken Nedergaard of the University of Rochester Medical Center.
"You can think of it like having a house party. You can either entertain the guests or clean up the house, but you can't really do both at the same time."
Co-authors of the study, which was funded by the US National Institutes of Health, came from Oregon Health and Science University and New York University.