The mechanism by which a good night's sleep improves learning and memory has been discovered by scientists.

The team in China and the US used more advanced microscopy to witness new connections between our brain cells - synapses - forming during sleep.

Their study is published in the journal Science, showed that even intense training could not make up for lost sleep.

Experts said it was an elegant and significant study, which uncovered the mechanisms of memory.

It is well known that sleep plays an important role in memory and learning. But what actually happens inside the brain has been a source of considerable debate.

Researchers at Newyork University School of Medicine and Peking University Shenzhen Graduate School trained mice in a new skill - walking on top of a rotating rod.

They then looked inside the living brain with a microscope to see what happened when the animals were either sleeping or sleep deprived.

Their study showed that sleeping mice formed significantly more new connections between neurons they were learning more.

And by disrupting specific phases of sleep, the research group showed deep or slow-wave sleep was necessary for memory formation.

During this stage, the brain was "replaying" the activity from earlier in the day.

Prof Wen-Biao Gan, from New York University, told the BBC: "Finding out sleep promotes new connections between neurons is new, nobody knew this before.

"We thought sleep helped but it could have been other causes, and we show it really helps to make connections and that in sleep the brain is not quiet, it is replaying what happened during the day and it seems quite important for making the connections."