Following a shaky start, the 25th-ranked Williams picked up her game in the second set and appeared poised to take over the match. The 18th-ranked Petkovic rallied in the third set, taking leads of 3-1 and 5-3, to beat Williams in their first meeting since Luxembourg in 2012.
Petkovic, making her debut in the tournament, is looking for her third title of the season. She also reached the semifinal at the French Open.
Varvara Lepchenko took care of qualifier Sachia Vickery, 6-1, 6-0, to earn her 400th career win, which includes all levels. She will meet third-seeded Angelique Kerber on Saturday night. Kerber topped Garbine Muguruza 6-2, 6-1.