Heffernan, fourth in the 2012 Olympic 50km and fourth in both walks at last year's European championships, broke clear of Mikhail Ryzhov after 35km to deny Russia a clean sweep of the walks after they took gold in both 20km events earlier in the week.
The Irishman, who withdrew before the 2011 race after his mother died suddenly, piled on the pressure in the latter stages, opening a 25-second gap going into the last 5km as the temperature rose following a cool start to the day and triumphed in three hours, 37 minutes and 56 seconds, the fastest time of the year.
Ryzhov took silver more than a minute behind while double Olympic silver medallist Jared Talent won bronze for Australia.
"I knew I was in the shape of my life, physically, mentally, preparation-wise everything was right and I had no excuses," he told journalists after winning Ireland's first world gold in 18 years.
"It was the Rocky scenario; I wanted to come here and beat the Russians in Moscow and that's what I did."
It was Ireland's third-ever world gold following the 5,000 metres victories of Sonia O'Sullivan in 1995 and Eamonn Coghlan in 1983.
"It's surreal, I can't quite believe it - though I always thought I could do it," he said. "When I came into the stadium and looked up at the big screen and saw myself it was like an out of body experience.
"Then I thought 'hey, I'm looking good and I'm going to win this' and was able to relax and really enjoy that final lap."
If anyone deserved to enjoy his moment in the sun it was Heffernan, who has worked long and hard with precious little reward in a backwater of the sport.
Racing the 20km distance he was 28th in the Sydney Olympics, disqualified in Athens and eighth in Beijing.
It was a similar story in the world championships and after finishing 15th in 2009 he had had just about enough of being an "also-walked."
However, encouraged by his hero, Poland's four-time Olympic gold medallist Robert Korzeniowski, he decided to carry on and came agonisingly close to a medal with two fourth place finishes in the 2010 European championships.
He travelled to South Korea a year later fully confident of going at least one place better, only to get the shocking news of his mother's death, leading to him returning home.
Putting more emphasis on the longer distance he finished ninth at the London Olympic 20km then took another fourth, having led early on, in the 50km.
"London was not a disappointment," he insisted on Wednesday.
"Everyone keeps telling me it was but I put in a great performance that just wasn't good enough to win a medal on the day."
Heffernan said his training and motivation since then had been ideal and he had to stop himself looking for excuses in the last few days before Wednesday's race. "Everything had gone perfectly and I just had to say to myself 'you have no excuses now, just go out there and execute the plan'.
"And that's what I did. I wanted to beat the Russians in their own back yard but I was just concentrating on my technique."
As the sun began to beat down after cool, wet conditions at the start, Heffernan began to pile on the pressure after around 35km. Ryzhov was the only man to stay with him but he eventually fell back as the gap stretched to 20 seconds with 5km to go.
Concentrating hard to avoid a heartbreaking late disqualification, Heffernan also made a mental note to complete the 500 metres circuit-and-a-bit of the Luzhniki track after
Russia's Elena Lashmanova almost blew her victory by stopping prematurely in Tuesday's 20km race.
His vast experience ensured he made no mistake, however, despite the pain of one of the most excruciating events in the programme.
"The last 10km are like a crucifixion so all you can do is prepare mentally for it," he said.
"But I was able to enjoy it at the end. Two years ago was the saddest time of my life, an awful experience I wouldn't wish on my worst enemy.
"That sort of thing helps you appreciate the good times."
Irish team mate Brendan Boyce, who finished 25th in a personal best time of 3:54.24, said Heffernan fully deserved his success after working so hard for so long and said the two planned to celebrate as only the Irish can.
"We are actually due to fly home very early tomorrow," Boyce said. "We'll see how that goes!"