Storl was trailing favourite Ryan Whiting when he launched an obviously big effort in the fourth round, only for it to be ruled a foul for his foot edging over the edge of the circle.
A long discussion with the judges followed, before a measurement was allowed and it proved well worth the trouble for Storl as his season's-best 21.73 metre effort was enough for gold.
American Whiting could not improve on his opening round 21.57 and had to settle for silver ahead of Canada's Dylan Armstrong who took bronze with 21.34.
Whiting came to Moscow with the four longest throws of the season but his failure to turn that form into gold continues the United States' recent run of failing to deliver in the shot in the biggest competitions.
There were also two field golds for the hosts as hammer thrower Tatyana Lysenko and long jumper Aleksandr Menkov, driven on by a raucous crowd, produced world-leading distances for victory.
Usually overshadowed by the track action, it was the field events that captivated a partisan crowd, who reserved the biggest cheers of the night for Lysenko and Menkov.
Lysenko's hammer victory got the Russian flags waving as the Olympic champion, who came back from a two-year doping suspension in 2009, set a championship record with a monster throw of 78.80 metres - the second furthest ever - and bowed to all four sides of the stadium in recognition of their support.
Next came Menkov, who broke the Russian long jump record twice on the way to winning with 8.56 metres in a final in which six men leapt over 8.20.
Four-times world champion Dwight Phillips of the U.S. had postponed his retirement in a bid for one final golden moment but the 35-year-old finished down in 11th with 7.88.