Heidemann was going after her second gold medal in a row in this event, but was fortunate to be in the finals after a semifinal victory over South Korean Lam Shin.
The clock malfunctioned with a second remaining in the match and eventually a few seconds were added to the clock. That gave Heidemann enough time to make the winning touch and break what had been a tie.
The South Korean delegation protested the outcome and when the ruling came down in favor of Heidemann, Shin and members of the delegation sat on the competition stage in protest.
The event was held up for more than an hour before the South Koreans relented. Shin then lost the bronze medal match to China's Sun Yujie.
In the gold medal match Shemyakina battled Heidemann on even terms through regulation and then recorded the first touch in extra time to win Ukraine's first gold medal of the Games.
It was the first medal of any sort for Germany, which has seen its status as a world athletic power diminish over the last two decades.
In each of the last four Olympics, Germany has won fewer medals than it did four years earlier. At Beijing, the Germans collected just 15 medals.
East and West Germany won 45 medals combined the last time they competed as separate countries at the Seoul Olympics of 1988.
Celebrity Breakups and divorces of 2014 [PHOTOS]