Djokovic, the two-time defending champion, raced through the first set in 27 minutes before Andujar picked up his game. The Spaniard, who had lost his previous meeting against Djokovic in straight sets, held at love to even the second set 1-1, drawing encouraging cheers from the crowd at the Indian Wells Tennis Garden.
Second-ranked Rafael Nadal defeated 21st-seeded Alexandr Dolgopolov 6-3, 6-2 to set up a quarter-final against David Nalbandian, who upset sixth-seeded Jo-Wilfried Tsonga 3-6, 7-5, 6-3.
No. 3 Roger Federer was to play a fourth-round match later, completing a parade of the world's highest-ranked players on a sunny, 27-degree day in the Southern California desert.
Azarenka routed fifth-seeded Agnieszka Radwanska 6-0, 6-2 in just over an hour to tie Serena Williams' 2003 record of 21-0 to start a season. The Belarusian has already won three titles this year, and now has her sights on Martina Hingis' record 37-0 start to the 1997 season.
"I was executing my shots brilliantly," Azarenka said.
Against Djokovic, Andujar held at 6-all to force a tiebreaker, which he won 7-5 as the Serb committed a slew of errors. Djokovic broke to open the third, then again to lead 5-2. He served out the match at 40-love, winning when Andujar's forehand service return sailed wide.
"He surprised me with his aggressive approach. He was taking the ball early and was playing well," Djokovic said. "Second set, I start playing a little bit more defensive, and that allowed him to come back to the match. All the credit for him to play the way he played. The second set I could have won, but I managed to stay calm mentally and just find my rhythm again."
Andujar fell to 1-8 against top-10 players, although he hung in for a stretch against Djokovic, keeping him on the run at the baseline with deep shots. The friendship between Djokovic and the 26-year-old Spaniard dates to when they played each other in an under-16 match in Belgium.
"I had six match points, and I lost that match 7-6 in the third set," Djokovic said. "We joke around a bit at the times when we were growing up."
Radwanska won two of the final three games in the quarter-final match to avoid a shutout in falling to 1-5 in her career against a No. 1-ranked player.
"I was (ticked), yeah, in the first set especially losing 6-love is not fun," she said. "Especially when you expect that you're at this kind of level that you can beat anyone. But then I was seeing that she was playing just too good."
All four of Radwanska's losses this year have been to Azaranka, including a straight-set defeat last month in Doha when Azarenka injured her ankle.
She kept playing, but appeared to be in pain and was visibly distraught. Radwanska later said she "lost a lot of respect" for Azarenka because her behaviour wasn't a good image for women's tennis.
"I hope I was a good example of women's tennis," Azarenka said Wednesday.
She had said earlier that she never had a problem with Radwanska, and the two women briefly clasped hands at the end of their latest match before walking away.
"It was the past, and now is a new tournament, new match," Radwanska said. "You know, everything from the beginning."
Azarenka also insisted there was no carryover from the situation in Doha.
"I have to play a very good match and show excellent tennis to beat her, so that's what I was mainly focused on," she said.
"She's the same person, same great player as she was before, and I have tons of respect to her game."
Other winners were: No. 11 seed John Isner, who defeated Aussie Matthew Ebden 6-4, 7-5; and No. 12 Nicolas Almagro, who defeated No. 7 Tomas Berdych 6-4, 6-0.
The top-ranked American doubles duo of twins Bob and Mike Bryan withdrew from their quarter-final match when Mike fell ill, although tournament officials didn't immediately say whether he has the same viral illness that has forced at least eight players out of the two-week tournament.