The 23-time Grand Slam singles champion beat her fellow American 6-3 6-4.
It is the 38-year-old’s first singles title since she won the Australian Open in 2017 and her 73rd WTA title overall.
Williams, in her fourth decade on the WTA Tour, lost the Wimbledon and US Open finals in 2018 and 2019 and retired from the 2019 Rogers Cup final.
She said after her victory that she would donate her prize money in Auckland and a dress she had worn to the Australian bushfire appeal.
“I have been playing for so long and been through so much and I’m happy to be doing something I love,” Williams said.
“I feel fortunate and blessed to be out here and to be healthy and to play.”
The Australian Open begins on 20 January, with Williams bidding to equal Margaret Court’s record of 24 Grand Slam singles titles.
Williams won her first WTA title in February 1999, when she beat France’s Amelie Mauresmo on carpet at the Open Gaz de France.
She made a slow start in Auckland, with Pegula taking a 3-1 lead in the first set, before recovering to win the next five games and close out the opening set.
Williams broke the unseeded Pegula’s serve early in the second set and converted her fourth match point to ensure victory.
She celebrated on court with her daughter, Olympia, with whom she was eight weeks pregnant when she won her last Grand Slam title in Melbourne.
She will be in action again later on Sunday alongside Caroline Wozniacki when they play Asia Muhammad and Taylor Townsend in the doubles final.