Much of the focus heading into the battle was on 22-year-old Ding, who last year won the World Cup and World Championships.
That meant she needed to emerge victorious at the Games to complete a Grand Slam, following in the footsteps of the great Zhang Yining.
But world number three and second seed Li had other ideas, with the 24-year-old's added power proving too much for Ding, who had to settle for silver after losing a tense encounter 4-1 (11-8, 14-12, 8-11, 11-6, 11-4).
Singapore's Feng Tianwei scooped her second medal by overcoming Japan's Kasumi Ishikawa to take bronze.
Feng prevailed 4-0 (11-9, 11-6, 11-6, 11-3), adding to the Team silver won alongside Li Jiawei and Wang Yuegu in Beijing 2008.
Li said afterwards: 'I'm very excited. This has been my dream since being a little girl. I dreamed of being an Olympic champion.
'We are the same level but today I performed better than I expected.'