The Dane had won just one set in seven harrowing defeats to Williams but she turned the tables with a 6-4, 6-4 victory in 89 minutes at the Singapore Indoor Stadium.
Wozniacki had some nervy moments after 37-year-old Williams, the tournament’s oldest ever finalist, clawed her way back from 0-5 down in the second set.
But she kept her cool to seal victory with a backhand down the line, throwing her racquet into the air and holding her hands to her face in disbelief.
“I am so happy I managed to win in the end,” said Wozniacki, describing the victory as “really sweet”.
“Eight is my lucky number. If I was going to beat her (Williams) once in my career, it had to be today.
“I couldn’t be happier right now. It’s been an amazing year. Last year was tough with injuries but I fought my way back and to stand here and win the title means a lot to me.”
Wozniacki has been in brilliant, aggressive form in Singapore, beating Elina Svitolina and Simona Halep at the group stage and Karolina Pliskova in the semi-finals.
After an even start, she seized control of the final by breaking four straight times across the sets to lead 5-0 in the second set.
With the title in her sights, Wozniacki was unable to serve it out in the seventh game and the ninth, when Williams produced an astounding crosscourt winner to win her fourth straight game.
But Wozniacki finally triumphed in the 10th game with her backhand down the line. She will now be third in the year-end rankings, after starting the tournament at sixth.
Williams looked increasingly weary as the match wore on after playing a gruelling, three-set semi-final against Caroline Garcia on Saturday.
“I didn’t seem to come up with my best tennis until it was too late,” the American said. “I love being here, it is an honour. Only eight players get to be here and I hope to return.”
In a contrast of styles, counter-puncher Wozniacki tried to extend the rallies while her big-hitting opponent attempted to shorten points through sheer power and rushes to the net.
Wozniacki broke three times in the first set and took a one-set lead when Williams played a loose service game at 4-5 down — just she second set she had ever conceded to the Dane.
Wozniacki, in her first WTA Finals since 2014, flourished in Singapore, with a tough three-set defeat to Caroline Garcia her only slip-up.
It completed a stellar comeback season for the two-time Grand Slam finalist, who endured an injury-marred 2016 and finished ranked number 19, her lowest position since 2007.
Williams was denied a 50th career triumph and first for the year, having finished runner-up at the Australian Open and Wimbledon.
She will remain the world number five after playing in her first WTA Finals since 2009.
Earlier, world number three pairing Timea Babos and Andrea Hlavackova won the WTA Finals doubles title on debut with a 4-6, 6-4, 10-5 comeback victory over Kiki Bertens and Johanna Larsson.