The unheralded American duo of Asia Muhammad and Taylor Townsend pulled off a notable upset, winning 6-4 6-4 to deny newly crowned singles champion Williams and former world No.1 Wozniacki.
For Williams, it was just the second women's doubles final defeat of an incredible WTA career, meaning her record in those matches stands at 23-2.
With Wozniacki retiring after the Australian Open, this was her last chance of a title in Auckland, where she was twice a singles runner-up.
The close friendship between Williams and Wozniacki was apparent, as the pair could be frequently seen in hysterics at the changeover between games, and both said afterwards they wished they had paired up earlier in their careers.
"We had a blast," Williams, who was a bridesmaid for Wozniacki last year, said.
But they could not get the job done on this occasion, with Wozniacki and all-time great Williams outfought under the floodlights.
Townsend served for the match and brought up three match points with an ace beyond the Williams forehand, clinching the title when Wozniacki netted on the backhand.
Wozniacki said: "Serena, thank you so much for playing doubles with me. It's been so much fun. I think my only regret in tennis is that we didn't do this earlier because I've had such a blast.
"It's rare that I have this much fun on court.
"It's really a fun way to finish off here in Auckland. I couldn't have scripted it any better - obviously I wished we'd have won today, but you guys did so good. We did our best. Congrats on the singles as well today, Serena.
"We have so much fun off the court and now on the court as well. I want to take a little credit for Serena winning the singles today because I think the doubles helped her."
Williams, filming her partner's interview on her smartphone, said her message to Wozniacki was: "Just congrats on an amazing career. It's not over yet. We have one more tournament to go of her being amazing."
That will come later this month at the Australian Open, the event at which Wozniacki won her one grand slam title in 2018.
"I had the most fun — maybe too much fun today," Williams said. "My only regret is we didn't do this sooner but at least we got to do it."