Williams had beaten Azarenka in straight sets in all three of their previous meetings and history repeated itself again, as she battled an hour and 42 minutes to take a tight two-setter, 6-4, 7-6(1).
It could have been over before the tie-break - Williams broke to lead 5-3 in the second set, and after losing that lead she held double match point up 6-5 on Azarenka's serve later in the set - but the two ended up going to that tie-break, where Williams stormed out to a 5-0 lead and never looked back.
"Obviously it's always great to get a win against a player like Victoria, because she's a champion, so it feels good," Williams said afterwards. "But also she hasn't been playing as much. I think she's still looking for her range. A lot of the time she played some great points but sometimes she had some errors she wasn't expecting, and I think that'll just clear up for her the more matches she plays."
Next up for Williams is No.8 seed Andrea Petkovic, who won her second round match on Wednesday. Williams leads Petkovic in their head-to-head, 2-1, and Petkovic's one win did come via retirement
This is the third time Williams and Ivanovic will play this year, Ivanovic winning at the Australian Open and Williams getting revenge in Rome. They've never played each other this much in one season.
"It's a good sign. It means we're getting further into the tournaments to play each other," Ivanovic said. "It's going to be a tough challenge, but at the same time it's a good test, because when you're starting out with a new coach it's good for them to see where you're at and what you have to work on."
Ivanovic's win over Zhao on Thursday was her WTA-leading 41st match win of the season.
With Thursday's win, Ivanovic also secures a return to the Top 10 on next week's WTA Rankings. She spent 108 career weeks in the elite between May 14, 2007 and June 7, 2009, including 12 weeks at No.1, but has been out of it for more than five years now - that will come to an end this Monday.