Down triple break point in the fourth game of the second set, Williams suddenly regained her trademark big serve to rally back.
Azarenka, who has yet to lose an official match this year, was broken six times in 10 service games.
Williams and Azarenka also played a couple of rallies left-handed in honor of Nadal.
Williams said Azarenka is one of the few players she is close to off the court.
“We really respect each other,” Williams said. “I love Victoria as a person. I love how she’s so competitive on the court.”