Needing to make the semi-finals to shut out his only challenger, 11-time champion Kelly Slater, Fanning clinched the title inside the last two minutes with his final wave.
Fanning required a 9.57 to beat Nicol and delivered a 9.70 with a deep barrel to edge the West Australian 17.03 to 16.90.
The Gold Coast surfer waited nervously on shore before the judges scores came through and he was chaired up the beach by the crowd with his arms raised.
"I just saw the set on the horizon, and I thought 'alright, whatever's going to come, I'm just going to try and pick the right one,'" Fanning said.
"That wave came and it was so beautiful.
"I'm just overwhelmed with emotion right now, its incredible."
It was the second last-gasp win of the day for Fanning who also trailed by a significant margin for the vast majority of his fifth round heat against 2001 world champion CJ Hobgood.
Fanning scored between the zeros and twos in his first eight waves against Hobgood and seemed totally out of sorts.
However, he then scored a 9.50 to pip Hobgood 12.00 to 10.50.
If Fanning had lost, he would have left the door open for Slater to win a 12th world title, though the American had to win the event.