Li won 21-15, 21-23, 21-17 in a 78-minute match of attrition that left both women bent over gasping for air at times.
The top-ranked Wang saved two match points in the second game but Li secured the win on her third in the decider. She tossed her racket and raised her arms, then saluted the crowd in Wembley Arena.
"I was quite tired at the end but you can never underestimate the aspiration of a player wishing to achieve the gold medal," Li said through a translator. "It was determination and persistency that made sure I was the winner today."
She was the last confirmed entry in the field less than a month ago, as China waited until the last possible moment to pick her over former No. 1 Wang Shixian. Li, who wasn't chosen for the world championships a year ago and started the year still relatively unknown, made herself impossible to ignore by winning 30 straight matches from February to June, including three against Wang, two of them in the All England and Asian finals.
"From being selected to today was a short while ago, and to be honest I'm still in a dream," she said. "My hard work ensured that I was selected."
Li, the world No. 3, also beat No. 2 Wang Xin in their all-Chinese semifinal. Li succeeded their coach, Zhang Ning, as Olympic champion.
"I congratulate my teammate for performing outstandingly," Wang Yihan said.
Earlier, Saina Nehwal became only the second woman from India to win a medal in the Olympics when Wang Xin retired injured during their bronze playoff and was taken to hospital. Wang Xin was leading 21-18, 1-0 when she collapsed a second and last time with a twisted left knee.
China team doctor Li Quanyi suspected ligament damage, and he and Wang criticized tournament referee Torsten Berg for not allowing anyone to wipe sweat off the floor that they blamed for her slip.
"She asked the referee to wipe the sweat but he wouldn't let her," the doctor said. "The referee should let athletes wipe the sweat."
Wang said she asked at least three times.
"I'm not trying to delay the competition because if they do come up and don't find any sweat on the floor then you can say I'm trying to delay the match," Wang said.
"If they won't let the court sweepers on then I can do it myself, but the thing is the referee didn't even allow me to do that and he wanted me to play on quickly."
Wang hurt herself while leading 20-18 and had the knee bandaged. She lasted only two more points, limped off the court with help and conceded the match.
Nehwal, ranked No. 5, offered her sympathies, and her supporters were understandably more animated at the result than she was.
"I had a feeling I was going to medal, just not this way. I wanted to have a good win," Nehwal said. "I was shocked at what happened. I was lucky today."
Because she thought Wang was tiring as their rallies got longer, Nehwal originally believed Wang deliberately sat down the first time to take a rest.
"I didn't think it was serious," she said. "Unfortunately it was, and it was really sad she got injured."
Nehwal also believed the Chinese were scared of her, thanks to wins over Wang and Li this year.
"I know they are scared of me, I can see it in their faces," she said. "I just have to work hard on my fitness and strategy for them because there's six or seven of them and just me."
The only previous Indian woman to medal was weightlifter Karnam Malleswari with a bronze in 2000. Nehwal hoped her medal will inspire more Indian women to play.
"I want more girls coming through, like in Korea and China, because then you get more results," she said. "It's happening slowly, I can see the changes, and I hope more girls play because of this medal."Suggest a correction