Azarenka suffers match-point meltdown in Williams loss
Azarenka served for the match at 6-5 and 40-0 in the third set but fell to pieces.
Williams fought back to 30-40 before Azarenka served three consecutive double faults to lose the game and was then defeated in the resulting tiebreak.
Williams eased through her first two matches but had a much tougher test against the hard-hitting Azarenka, ranked 31, who is rediscovering her form after an injury plagued 2014.
Both players had their serves broken in a tight first set before Williams came back from 5-1 down in the tiebreak to win 7-5.
The American looked in control as she broke in the fifth game of the next set but then lost her concentration.
She started making unforced errors and threw her racket to the ground as she went on to drop her next two service games and the set.
Azarenka, a former world number one and twice Australian Open winner, again came from a break down in the decisive set and was poised to get the better of Williams but the tension got to her in a spectacular stumble.
Williams, who is gearing up for Roland Garros where she is looking to win her 20th grand slam title, will now play the winner of Carla Suarez Navarro’s game against Ana Ivanovic.
Defending champion Maria Sharapova needed all her battling qualities to beat France’s Caroline Garcia.
The Russian edged through 6-2 4-6 7-5 after fending off a brilliant comeback from the world number 28.
Fourth seed Petra Kvitova played some of her best tennis of the week to see off Anastasia Pavlyuchenkova 6-1 6-4 in little more than an hour, committing only eight unforced errors.
The powerful Czech will play Romania’s Irina Begu for a place in the semi-finals while Sharapova’s next opponent will be former world number one Caroline Wozniacki who beat Agnieszka Radwanska 6-3 6-2.
In the men’s draw, David Ferrer faced a repeat of his second round match in Madrid last year but this time had no trouble crushing fellow Spaniard Albert Ramos 6-4 6-0, while sixth seed Tomas Berdych beat Richard Gasquet 7-6(3) 7-5.
(The story was refiled to make clear Azarenka’s three double faults were not all on match point)
(Reporting by Tim Hanlon in Barcelona; editing by Toby Davis)