The world number one battled back from a set down in a tense centre court match against the 24th seeded Spaniard to win 2-6, 6-3, 6-2 and make the quarter-finals, staying on track for a 19th Grand Slam title and her sixth at Melbourne.
"I didn't start out so well and she did everything she needed to do in the first set," said Williams, who can lose her top ranking if she exits and Maria Sharapova wins the tournament.
Williams was seen coughing throughout the match and confessed that "I've been a little sick in the last couple of days".
She will next face last year's finalist Dominika Cibulkova, the 11th seeded Slovak who ended the comeback from injury of Azarenka in three tight sets.
Her sister Venus has a chance of joining them in the last eight, facing gritty Polish sixth seed Agnieszka Radwanska in a night match with the evergreen 34-year-old in the second week of a Slam for the first time since Wimbledon 2011.
World number one Novak Djokovic takes on unseeded Gilles Muller of Luxembourg later Monday with the winner playing Canadian eighth seed Milos Raonic or Spanish 12th seed Feliciano Lopez in the last eight.
