Knocked off his board by a shark, a surfer punched his attacker during the televised finals of a world surfing competition in South Africa before escaping.

Australian surfer Mick Fanning was attacked by the shark during the JBay Open in Jeffrey's Bay in the Eastern Cape Province but escaped without injuries.

On a video on the World Surf League's website, Fanning is seen being knocked off his surfboard.

As he scans the water, two fins appear and he disappears under the surface. He is next seen furiously trying to swim to safety before a rescuer pulls him out of the water.

Back on land and shaking his head in disbelief, Fanning told spectators that he punched the shark.

The World Surf League cancelled the remainder of the event.

"I felt something grab, get stuck in my leg rope and instantly jump away. And it just kept coming at my board," Fanning said, once safe on the rescue boat.

Fanning said at first he swam away but then decided to defend himself and turned to punch the shark in the back.

"I saw it taking my board away and I just started cracking it," he told a crowd that gathered around him once he was back on shore, referring to how he struck the shark.

"I'm totally fine. I've got nothing wrong with me," Fanning said in an interview. "There's a small depression in my board and my leg wrap (was) bitten. I'm just totally tripping out. To walk away from that, I'm just so stoked. Oh man."

The World Surf League cancelled the remainder of the event and Fanning will split the prize money with fellow Australian surfer Julian Wilson, who was also in the water when the attack happened. The two will share second place.

"We are incredibly grateful that no one was seriously injured today," the league said in a statement. "Mick's composure and quick acting in the face of a terrifying situation was nothing short of heroic."

Commentator Ross Williams said there are occasionally shark sightings in and around events but an actual attack was very unusual.

"For it to happen in that fashion during the finals, where it actually showed that crazy aggression toward Mick Fanning, such a crazy thing," he said on the video.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.