Heffernan's gold came 30 years to the day after Eamonn Coughlan won the 5,000 metres in 1983. Ireland's last gold medal was 18 years ago when Sonia O'Sullivan won the 5,000.
The walk began shortly after an early-morning storm and finished in warm sunshine 3 hours, 37 minutes, 56 seconds later, the time it took Heffernan to cover the grueling distance. He was fourth at last year's Olympics.
"I didn't get carried away for any part of the race. I was just going K by K (kilometre by kilometre), and I tried not to get emotional about anything," Heffernan said. "It was only coming into the stadium I felt as if I was watching myself on the outside, like I was looking at myself on the big screen. And I felt 'It looks good ... you look good, like.' So I just rolled with it."
Mikhail Ryzhov of Russia took the silver, 1:02 behind, and Jared Tallent of Australia, silver medallist at the past two Olympics, had to settle for bronze, 2:07 back. He also won the bronze at the worlds two years ago.
Olympic champion and 2009 world gold medallist Sergey Kirdyapkin pulled out shortly before the championships.
Evan Dunfee of Richmond, B.C., was 36th in a personal-best time of 3:59:28.
"I was expecting to be a little faster and move up a couple more places," said Dunfee. "I would have loved to have been 10 spots higher but I am going to take this and move forward."
With no evening session, the walk was the only medal event Wednesday.
Ryzhov and Tallent were among the early leaders that also included Ivan Noskov of Russia, Yohann Diuniz of France and Grzegorz Sudol of Poland, with the lead switching hands.
Heffernan joined the group halfway into the race and by the 37th kilometre he and Ryzhov were slightly ahead.
At the 40th, Heffernan had a 12-second lead over Ryzhov. He increased that to 18 seconds with five kilometres left.
The Irishman kept building his lead and was smiling broadly as he entered the sparsely filled Luzhniki Stadium on his own.
After wrapping himself with an Irish flag, he embraced his wife Marian.
Angel Garcia of Spain, the 1993 champion and the oldest competitor at the championships at 43, finished 12th.
Nearly an hour after the winner, John Nunn of the United States walked into the stadium, wildly cheered by volunteers, the only people left in the stands. He collapsed after crossing the line, crying in pain from cramps as the medics put ice on his body.
In other morning events, Dwight Phillips of the United States stayed on course for a possible fifth world title by qualifying for the final of the long jump. Phillips jumped 7.95 metres, his personal best this season.
But Phillips will have to do a lot better than that to win gold.
Eusebio Caseres led all qualifiers with a leap of 8.25 metres. Luis Rivera of Mexico, who leads the season's world list with a jump of 8.46, qualified at 8.04.
But Olympic champion Greg Rutherford of Britain, recovering from a hamstring injury, failed to make the final with a best effort of 7.87.
"I'm not hurting now, which is massive. I've done something incredible in coming back five weeks after not just a tear, I ruptured one of my hamstrings and split it in half," Rutherford said. "I felt great, running down the runway I felt fast, on plant I didn't hurt and after the first round I genuinely thought I could do something - but it wasn't good enough today."
The favourites advanced in the women's 5,000, led by Olympic champion Meseret Defar of Ethiopia, who topped all qualifiers in 15:22.94. Defar was the 2007 champion in the distance and also has a silver and a bronze in past championships.
Ethiopian teammate and world-record holder Tirunesh Dibaba, who won the 10,000 on Sunday, decided not to go for the double.
Margaret Wangari Muriuki of Kenya pulled up with a hamstring injury.
Asbel Kiprop of Kenya, the defending 1,500-metre champion and the 2008 Olympic gold medallist , led all qualifiers for Friday's semifinals in 3:38.15. Kiprop has been dominant this season, three seconds faster than anyone else.
Nathan Brannen of Cambridge, Ont., was fourth in 3:38.49.
"It was much easier than I expected, I got close to the front and covered the moves, that was the plan," he said. "After last year, falling at the Olympics, I just wanted to stay out of trouble, got out well, stayed with the front."
Silas Kiplagat, who beat Kiprop at the Kenyan trials, topped his group, ahead of Olympic silver medallist Leo Manzano of the United States.
In the women's hammer throw, Anita Wlodarczyk of Poland led the qualifiers with a throw of 76.18 metres, while former world champion and Olympic bronze medallist Betty Heidler of Germany failed to advance to the final.
World and Olympic champion Tatyana Lysenko of Russia was safely through.
Sultana Frizell of Perth, Ont., failed to advance.