Williams hadn't won a title since the Australian Open singles tournament in January 2017, and she hadn't won one since she became a mother to her daughter, Olympia, who was courtside to witness the victory.
The 23-time major winner donated her $43,000 winner's check to the fundraising appeal for victims of Australian wildfires, joining many other tennis stars -- including Ashleigh Barty, Nick Kyrgios, Novak Djokovic and Maria Sharapova -- who have pledged money to the already monthslong fire emergency.
Williams was under pressure at first against Pegula, 25, who was playing in her third WTA final, but Williams asserted herself as the match went on to claim her 73rd win in 98 finals and add her name to a trophy won by her sister, Venus, in 2015.
"It feels good. It's been a long time," Williams said. "I think you can see the relief on my face.
"I played an incredible opponent today in Jessica, and honestly, it was a great match, and I couldn't have played anyone better in the final."
The past three years have been challenging for Williams, as she has juggled the competing demands of tennis and motherhood. The 1,079 days between her Australian Open win and Sunday's victory in Auckland marked the longest title drought of her career.
But she seemed to turn a corner during a demanding week in which she played both doubles and singles, turning out on all seven days of the tournament.
Williams was frequently behind in her matches but showed typical determination to fight her way to the final and overcome Pegula, who ousted former world No. 1 Caroline Wozniacki in the semifinals.
Pegula has been on a steady climb up the rankings since she overcame a serious knee injury two years ago. A daughter of Buffalo Bills owners Terry and Kim Pegula, she won her maiden WTA title in 2019 and appeared to be a star on the rise in all her matches in Auckland.
Pegula broke Williams in the opening game and was dominant for the first half of the first set, moving Williams around to open the court for her punishing passing shots. She also chased down everything, making returns that Williams thought out of her reach.
Williams visibly called on herself to lift near the middle of the set, breaking to level at 3-3. She then held serve to love and broke Pegula for 5-3, serving out the first set in 51 minutes.
Williams broke Pegula to love in the third game of the second set as she began to dominate. She had three match points on Pegula's serve before clinching the match on serve in just over 90 minutes.
"It definitely feels good," Williams said. "It feels that I was definitely improving as the week went on."
Williams might have had two titles on the same day, but she and longtime friend (and first-time doubles partner) Wozniacki were beaten 6-4, 6-4 by Americans Taylor Townsend and Asia Muhammad in the doubles final.
Wozniacki was playing her second-to-last tournament before retirement -- the Australian Open will be her last -- and she fulfilled a long-held ambition in Auckland to team with Williams in doubles.
The pair progressed easily to the final but were overwhelmed on Sunday by Townsend and Muhammad, who were a more practiced and efficient combination. The young Americans broke the two former singles No. 1s in the third and seventh games of the first set and claimed the only break of the second set in the third game.
ESPN Stats & Information and The Associated Press contributed to this report.