won gold in the men's 20km walk
to become China's first race walker to win an Olympic medal.
Compatriot Zhen Wang was also among the medals as he finished third behind Erick Barrondo of Guatemala.
Ding, 19, was taking part in his first major championships and timed his move to perfection as he raced clear of the rest of the chasing pack.
2008 Olympic champion Valeriy Borchin collapsed just minutes from the line and had to receive medical treatment.
He eventually left the course on a stretcher.
Luis Fernando Lopez of Colombia and Russian Vladimir Kanaykin, who were both part of the five-man chasing pack, were disqualified in the latter stages.
There were no British entries in the race but Dominic King will go for gold in the 50km walk, which takes place on Saturday 11 August.