Defending champion was below his emphatic best and will face Japanese No 1 Nishikori for a place in the semi-finals
Shanghai Masters: Roger Federer pushed all the way as Novak Djokovic gains revenge
Roger Federer was once again pushed to the limit at the Shanghai Masters before edging out Spain's Roberto Bautista Agut 6-4, 2-6, 6-4 to reach the quarter-finals on Thursday.
Federer, the top seed and defending champion, looked comfortable after taking the first set with a solitary break of serve in the fourth game. The Swiss world No 2 opened the second set with another service break and looked to be cruising to victory, only for his own serve to completely fall apart, getting broken three times as Bautista Agut levelled the match.
The decisive set proved a tense affair, with the all-important break arriving in the ninth game, although Bautista Agut can feel somewhat aggrieved by an incorrect line call and the umpire's decision to replay the point, despite Federer hitting his forehand into the net before the call.
Shanghai Masters talking points: Novak Djokovic continues putsuit of Rafael Nadal
That would have put the Spanish world No 28 one point away from a 5-4 lead. Instead, a series of sparkling shots from Federer eventually resulted in the Swiss forcing the break before serving out the match to love.
Federer's narrow victory was similar to his second round win over Russian Daniil Medvedev a day earlier, when the 20-time grand slam champion looked comfortable at a set up before surrendering the second and narrowly edging the third.
Federer will take on Kei Nishikori for a place in the semi-finals after the Japanese No 1 defeated American Sam Querrey 7-6, 6-4.
Djokovic gains revenge
Novak Djokovic claimed a measure of revenge against Marco Cecchinato at the Shanghai Masters as the second seed thrashed the Italian 6-4, 6-0 to reach the quarter-finals.
Djokovic, the second seed in Shanghai, was surprisingly defeated by Cecchinato in the French Open quarter-finals in June, during a time when the 31-year-old Serbian was struggling to rediscover his form after returning from elbow surgery.
That defeat proved to be a turning point as Djokovic embarked on a run of results that saw him win Wimbledon and the US Open. The world No 3 again demonstrated his vast improvement in form by dismantling Cecchinato in just 70 minutes.
Djokovic will face the man he beat in the Wimbledon final for a place in the Shanghai semi-finals after Kevin Anderson came through a tight encounter against Greece's Stefan Tsitsipas 6-4, 7-6.
Djokovic is aiming to close the gap on world No 1 Rafael Nadal - who is absent with injury this week - and the 14-time major winner will replace Federer as No 2 if he reaches the final.
Alexander Zverev was similarly emphatic as he brushed aside Australia's new No 1, teenager Alex de Minaur, 6-1, 6-4.
The German fourth seed will face 11th seed Kyle Edmund in the last eight after the British No 1 defeated Chile's Nicolas Jarry 7-6, 6-3.
Zverev, 21, was ruthless as he took the first set in just 29 minutes, although his 19-year-old opponent showed more fight in the second.
Zverev has been suffering with a cold but ratcheted up the pressure to grab the all-important break of serve in the ninth game before closing out the match.