Waste toxins built up in the brain are washed away by sleep, a new US study has found.
The team at the University of Rochester Medical Center believe that waste removal is one of the key reasons for sleep.
Published in the Science journal, the study found that brain cells reduce in size during sleep. This opens up gaps between neurons and allows fluid to clean the brain.
Researchers believe a deficiency in the way these toxins are removed could play a role in brain conditions.
For many years scientists have tried to understand why people need to sleep. It has been found to help memories fix in the brain, but this study suggests its primary purpose is "housework".
Dr Maiken Nedergaard, who led the study, said: "The brain only has limited energy at its disposal and it appears that it must choose between two different functional states - awake and aware or asleep and cleaning up.
"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."
Damaged proteins in the brain play a major part in conditions such as Alzheimer's disease and Parkinson's.
Researchers hope this latest study will be able to new investigations on the conditions.
It is estimated that 820,000 people are currently living with dementia in the UK, while there are around 127,000 people with Parkinson's.
Earlier this year, scientists at the University of Wisconsin found that sleep increases the production of cells which insulate circuits in the brain in tests conducted on mice.
The increase was found to be most striking during rapid eye movement – the part of sleep associated with dreaming.
In contrast, cells became stressed and even died when a subject was forced to stay awake.