The Australian surfer was struck by the shark from behind and knocked into the water as he sat on his board waiting his turn during the JBay Open in Jeffrey's Bay in the Eastern Cape Province.
As he scans the water, two fins appear and with a splash he disappears under the surface. He is next seen furiously trying to swim to safety before a rescuer pulls him out of the water.
"A big sigh of relief seeing Fanning in one piece," a commentator is heard saying, on the video of the event posted on the World Surf League website.
"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."
Fanning's mother, Elizabeth Osborne, who watched the incident live on television in Australia, wept as she told Australian Broadcasting Corp. radio the attack was "the worst thing I've ever seen happen to any of my family because it was just there in front of me."
"It was absolutely terrifying. I actually got up and walked across to the television because I just couldn't believe what I was seeing and I thought we lost him," she said in an ABC TV interview. "I went over to the television almost as though I could pull him out of the television. I just wanted to save him really, but there was nothing I could do."
Osborne said she believes Fanning's brother Sean, who died in a car accident 17 years ago, was watching over his sibling.
Surfing great Kelly Slater said he was coming up the beach when he saw all the boats and skis heading toward the surfers.
"I knew there was only one possible reason that would ever happen in a contest and that's if someone got attacked by a shark," Slater was quoted as saying. "I'm halfway between crying and laughing because he got so lucky. I'm lost for words to be honest."
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.
The website for the World Surf League is www.worldsurfleague.com
Also on HuffPost