The 21-year-old failed to convert two match points in the second game but managed to summon enough energy to clinch a draining women's Singles final 21-15 21-23 21-17.
Wang, the world champion and world number one, had long seemed destined for the top prize but third seed Li's form throughout the week had suggested she could cause an upset.
Saina Nehwal of India took bronze as China were denied all three podium positions after an injury to second seed Wang Xin.
Wang Xin jarred her knee late in the first game against fourth seed Nehwal and play was delayed for her to receive treatment.
She picked herself up to win the point that secured the first game and then won the opening rally of the second but collapsed moments later.
It soon became apparent the match would not continue and Nehwal was awarded the match with the score 21-18 1-0 against her.
That meant India had their first Olympic medal in Badminton but Nehwal respectfully did not celebrate as she left court.