Hafnaoui was the stunning winner of the 400 metres freestyle at the Tokyo Games on Sunday, beating a field of faster and older swimmers.
He was the slowest qualifier to start the final.
“I believed it when I touched the wall and I saw myself first,” he said. “I was so surprised.”
Australia’s Jack McLoughlin earned silver and American Kieran Smith took bronze. The top three were separated by less than a second after the eight-lap race.
“When I hit the water, I was just thinking about the medal, not the time,” Hafnaoui said.
He squeaked into the final by 14-hundredths of a second, landing him in the far outside lane. The fastest qualifiers were in the middle of the pool, without the ability to track Hafnaoui during the race.
Asked what he knew about Hafnaoui, Smith said, “Absolutely nothing.”
Hafnaoui joined Ous Mellouli to be the only Tunisians to win a gold in swimming.
Mellouli won the 1,500 metres freestyle at the 2008 Beijing Games, one of his three career Olympic medals.
The teen, who trains in the capital, Tunis, is the North African country’s fourth Olympic gold medallist. He is the second-youngest athlete from an African nation to win a swimming gold.
Standing on the podium, and his coach furiously pumping his arms in triumph in the stands, the moment was overwhelming for Hafnaoui.
“I was in tears because when I see the flag of my country and I hear the anthem in the background, it was great,” he said. “I’m so proud of it. I dedicate it to all the Tunisian people.”