Williams’ bid for a third title at Roland Garros looked to be over when she trailed a set and 4-2 but the American turned the match on its head to win 3-6 6-4 6-2.
Azarenka threw away a one-set lead against the same opponent only three weeks ago in Madrid and the Belarusian was furious when a decision went against her at the end of the second set.
On set point, Azarenka’s forehand was called out but the umpire overruled, deeming the ball in and ordering the point to be replayed.
Williams had hit the ball into the net, seemingly regardless of the call, and Azarenka felt the error should have stood.
The Belarusian was given a warning for a visible obscenity after the controversial point, which proved to be crucial.
Williams, who had now rediscovered her rhythm after a disastrous opening set, won six out of the next eight games to complete a sensational comeback and move into the next round.
It is only the second time in five years the 19-time grand slam champion has made it past round three in Paris and she will now play fellow American Sloane Stephens for a place in the quarter-finals.