Mellouli thought he had reached the peak of his career when he upset Australia's Grant Hackett to win the 1,500 metres freestyle gold medal at the 2008 Beijing Games.
However, the 28-year-old surprised himself by winning the 10 kilometre marathon on Friday to become the first swimmer to win Olympic medals in the pool and open water, having won bronze in the pool earlier these Games.
Exhausted after churning through the Serpentine lake in Hyde Park for nearly two hours, he thumped his chest with pride then said he was considering going out on top.
"After winning this gold I will definitely think about retiring because I don't think I can top this achievement," he said.
"I can't do any better than this. It might be a good time to leave the sport with this incredible gold medal."
Mellouli, who won gold in Beijing after serving an 18-month doping suspension for taking a tablet that contained amphetamines on the banned list, has had a tough time since winning in China.
He has struggled with shoulder and elbow injuries for the past three years and lost his reign as the world's best 1,500 swimmer to China's Sun Yang, who broke his own world record to win the gold in London, with Mellouli coming third.
"Only those close to me know how much I struggled to get here today," he said.
"I struggled for three years with my shoulder and not having the training that I really wanted to. I have no regrets to leave it all behind and enjoy life."
Despite being one of the fittest swimmers in the world with a tough training regime, Mellouli said the 10km race was the toughest event he had done in his life.
"That was hell. There is no other way to describe it," he said.
"The last 100m, as I lifted my head to look at the finish line, my shoulder was so heavy, my legs were tight, my lungs were burning, my whole system was in shock for the last five minutes.
"It's like what a marathon runner goes through but it's even more painful than that. The 10km is probably one of the toughest events in all sports combined."
A versatile swimmer who trained and studied in California, Mellouli won the 800m world championship in 2007 but was later stripped of his title and suspended after it was revealed he tested positive for amphetamines at a meeting in the United States in late 2006.
Mellouli said he had taken a pill two days before he tested positive so he could stay awake to finish a university assignment.
"That 2007 hiccup, it was obvious to the world of swimming that it was just a mishap," he said.
"It was a mistake that truly changed me as an athlete and made me more aware of my responsibilities.
"I get tested at least 10 times a year, no problems. I got my redemption in 2008. It's a completely different story now: years of sacrifice and hard work."