After an early exchange of breaks, the 20-year-old Serb took Andreev's serve in the fourth game with impressive returns and wrapped up the set with a beautifully executed volley.
But the Russian had no intention of lying down in their third round match and pulled back into contention by taking the second set having broken in the fourth game.
Leg injury
Djokovic looked rattled for a spell and came close to losing his serve again three times before regaining his composure to break in the second game of the final set.
Serbia's world number three had to dig himself out of more trouble in the seventh game of the decider before serving out the match.
Davydenko hauled himself level from two breaks down in the final set against 14th seed Robredo and then recovered another dropped service game before losing the match in a tiebreak.
Robredo will face top American Andy Roddick, who took out the last Italian with a 7-6 6-3 victory over Simone Bolelli, a surprise finalist in Munich last weekend.
Stepanek set up a match against Federer by ending Peruvian qualifier Luis Horna's impressive run with a 6-4 1-6 6-3 win.
Almagro reached the last eight when Chilean Fernando Gonzalez, last year's finalist, pulled out of their match with a leg injury.
Juan Carlos Ferrero failed to build on Wednesday's shock win over fellow Spaniard Rafael Nadal and was beaten 6-4 6-3 by Switzerland's Stanislas Wawrinka.
Wawrinka will be pitched against American eighth seed James Blake, who rallied to beat Spain's Fernando Verdasco 5-7 7-5 6-2.
(Agencies via Shanghai Daily May 9,2008)