Ratchanok, 18, becomes the first ever Thai player to win gold at the world championships after defeating 22-year-old top seed Li, who was gunning for her first world title.
The three-game thriller was a battle of technical skill and stamina, with Ratchanok pushing a more experienced Li around the court with a sophisticated repertoire of shots.
Ratchanok came back from 19-12 down in the first game to clinch it by two points, with a grim-faced Li fighting back to take the second.
At the end of the match Ratchanok dropped to her knees in tears on court before bowing to an applauding stadium.
A smiling Ratchanok, who still has braces on her teeth, said she would meet Thailand's Queen Sirikit on Monday, which is a national holiday to mark the queen's birthday and Mother's Day.
"I am going to bring my victory to the queen and to my mother and godmother as a gift," Ratchanok said.
"Before this match I didn't have confidence when I was competing against the top players, but after today I will.
It was a fairytale moment in a career that started when she was five years old and her parents were working in a dessert factory, taking Ratchanok with them each day.
