Azarenka's 15 double faults, to go with 44 unforced errors, mirrored her erratic display over two hours 22 minutes against Petkovic who appeared to be feeling dizzy in the second set.
The loss for second seed Azarenka followed her second-round defeat by Venus Williams in Tokyo last week.
Petkovic looked in discomfort in the second set, needing medical time out, and she lost seven straight games as Azarenka forced the decider.
The defending champion traded breaks with Petkovic to level at 4-4 in the third set but her 15th double fault on break point left the German serving for the match.
Image: Andrea Petkovic
Photograph: Lintao Zhang/Getty Images
Tokyo tears: Venus denied fastest serve in absence of technology
Czech pair Hlavackova-Hradecka win U.S. Open women's doubles
Three cheers for World No 1 Serena Williams
Wozniacki, Williams: VOTE for BEST dressed player at US Open
Serena Williams is 'best ever' but Azarenka 'closing the gap'