Australian Blake Johnston on Friday shredded the world record for the longest surfing session, dodging swarms of jellyfish to ride hundreds of waves across 40 punishing hours.

The 40-year-old former surfing pro broke down in tears after smashing South African Josh Enslin's previous record of 30 hours and 11 minutes.

Johnston surfed back to shore in the evening to rapturous applause from the hundreds of supporters who had gathered at Sydney's Cronulla Beach to watch.

Wearing a black cowboy hat and draped in a thermal blanket, he was carried off the beach on his friends' shoulders after finally hanging up his surfboard.

Johnston raised more than Aus$200,000 (US$133,000) for mental health, taking on the record to mark 10 years since losing his father to suicide.

He rode more than 700 waves in setting the record, braving pitch-black seas that are home to many species of shark.

"I've still got a job to do. I said 40 (hours) so I'll go and give it a crack," he told reporters earlier in the day, after passing the previous 30-hour record.

"I'm pretty cooked, yeah, but we'll push through."

Johnston eventually surfed for more than 40 hours -- he started at 1:00am on Thursday, using large spotlights to illuminate the water -- but his official record time was not immediately known.

Under the rules of the attempt, he was allowed to sporadically leave the ocean so he could soothe his eyes with eyedrops, refuel with snacks and lather himself up in sunscreen.

Medics would check his heart rate and blood pressure before he dashed back into the swell.

With Sydney in the grip of a minor heatwave, the water temperature has been hovering around a balmy 24 degrees Celsius (75F), lessening the risk of hypothermia.

- 'Only 30 hours' -

Johnston had originally planned to raise money by tackling a 1,000-kilometre run (620 miles), but settled on surfing when he saw the previous record was "only" 30 hours.

"I thought I could just do it," he said before the attempt.

"I push myself to the limits with my adventures and to prove to myself that I'm worthy and can get through hard times, and that's when my lessons are learnt."

He anticipated infected ears, dehydration and sleep deprivation would push his body to its limits.

Johnston's brother Ben said they had also prepared for the possibility of a shark attack, but it wasn't something that had worried them.

"I surfed at two in the morning with him and the lights actually went out so it was pitch black," he told national broadcaster ABC.

"There were a whole bunch of jellyfish out there, so it was interesting to say the least."

It is not Johnston's first time taking part in a marathon test of human endurance.

In 2020, he ran 100 kilometres along the rugged coastline south of Sydney -- covering the vast majority of the trek in bare feet.