Media playback is unsupported on your device Media caption Matthew Rees helped David Wyeth up The Mall to the finish line of the London Marathon

It's been hailed as the defining image of this year's London Marathon: runner Matthew Rees stopping to help fellow competitor David Wyeth after he almost collapsed just metres from the finish line. But why do some runners' legs turn to jelly?

With the end in sight, David Wyeth's legs began to buckle. Staggering along The Mall, head dropping, it looked like he would not complete the race.

But - in a show of comradeship that has quickly gone viral - fellow runner Matthew Rees stopped, pulled Mr Wyeth up and they completed the 26.2 mile challenge together.

"I saw David and his legs had completely collapsed beneath him," the Swansea Harriers runner told BBC Breakfast.

"I went over and he said 'I've got to finish' and I said 'you will' and I helped him up."

'Out of petrol'

His struggle is reminiscent of an exhausted Jonny Brownlee, who was helped over the finish line by brother Alistair in the Triathlon World Series in Mexico last year.

Jonny required treatment but later tweeted he was OK, with a photo of himself lying in a hospital bed on a drip.

Media playback is unsupported on your device Media caption Jonny Brownlee helped over finish line by brother Alistair in Mexico

At the time, Alistair said: "I wish the flippin' idiot had paced it right and crossed the finish line first.

"You have to race the conditions. I was comfortable in third. I raced the conditions, I took the water on, made myself cool and I was alright."

London Marathon Coach Martin Yelling says it is like runners have "run out of petrol".

"At the end of a marathon runners usually have given so much physically that their energy levels are completely depleted - the term is hitting the wall," he says.

"What that means is your body is struggling to find enough physical energy to move forward, the body is trying to tell you to stop."

He says there is a clear wrestle between physical exhaustion and "incredible mental strength" in runners who have hit the wall.

"For every-day runners it is about learning to understand how your body responds.

"We would call it listening to your body."

Training for a marathon, pacing yourself and the correct fuel and hydration is important in avoiding the wall and the so-called "jelly legs", he says.

Image copyright Reuters Image caption Other runners were helped by others as they collapsed before the London Marathon finish line

Tim Navin-Jones, from running club London City Runners, is one runner who can sympathise, having "hit the wall" himself during the New York Marathon.

"Your mind is telling you to keep going and your body is getting to the point where it says 'no'," he says.

"Your legs really do turn to jelly - it is horrific.

"It is like being a really horrible version of drunk. It is sheer exhaustion."

Mr Navin-Jones, who has run five marathons among other distances, says it is difficult to know how to pace a marathon for those who have not done it before.

A common mistake is runners starting a race too fast, he says.

'Sheer exhaustion'

Emma Ross, head of physiology at the English Institute of Sport, says runners "hit the wall" in a marathon when they run out of carbohydrate to use as a fuel for running.

"So what you want to try and do is keep your carbohydrate stores topped up during the race to prevent you from predominantly having to use fat as a fuel," she says.

"When we use fat as a fuel, we have to go slower because as a process of burning energy it is a more complex and a slower system, so we can only support slower exercise."

She also warns that dehydration causes a decrease in blood volume, which makes the heart work harder, so it is important for runners to keep hydrated.

Runner Gary McKee completed 100 marathons in 100 days for MacMillan Cancer Support, finishing on Sunday at the London Marathon.

Image copyright Macmillan Cancer Support Image caption Gary McKee completed 100 marathons in 100 days for MacMillan Cancer Support, raising more than £67,000

The 47-year-old, from Cleator Moor in Cumbria, says he managed to not hit the wall as he paced himself carefully during his challenge.

He says runners have to recognise when their body is telling them to stop.

"It is down to hydration. You will come to a point when you are tired.

"Have you overexerted yourself? Have you had enough calories? Enough carbs?

"The more you train, the higher your fitness levels become, so you can sustain it (running) for longer.

"If you understand what your body wants, just give it what it wants."