An irate Roger Federer and defending champion Novak Djokovic both suffered quarter-final defeats on a dramatic day at the Shanghai Masters.

Federer’s 6-3 6-7 (7) 6-3 loss to Alexander Zverev will go down as one of the more talked-about matches of the ATP Tour season.

Zverev, who has burst into life after a difficult season, missed five match points in the second set, with Federer finding some magic to win five straight points from 40-0 at 6-5 and then saving two more in the tie-break.

There was more drama in the deciding set, with Federer quickly going down 3-0 and then engaging in a furious dialogue with the umpire after being given a rare point penalty for hitting a ball into the stands for a second time.

Zverev managed to keep his cool and served out the victory at the second time of asking, taking his sixth match point.

The German joins Djokovic and Rafael Nadal as the only active players who have faced Federer at least seven times to hold a winning record against him.

Zverev said on atptour.com: “(I’m) finally starting to kind of play the way I should play, really. I was playing really defensive the whole year, and I was not with a lot of confidence.”

Djokovic had reached at least the semi-finals on all eight of his previous appearances at the tournament but he fell to a 3-6 7-5 6-3 defeat by a resurgent Stefanos Tsitsipas.

The young Greek has had a difficult time over the last few months but was on top form here and it was a double celebration as he also secured qualification for the ATP Finals next month for the first time.

Tsitsipas said: “It’s the best comeback that I have ever had probably. It was a very difficult victory mentally, too. I wasn’t really thinking that long term that I have to win two sets. It just went step by step.”

The defeat is a major blow to Djokovic’s hopes of finishing the season ranked world number one.

Although he will stay ahead of Nadal for now, the Spaniard does not have any points to defend over the closing weeks of the season and is in pole position.

Djokovic said of Tsitsipas: “He had the high-quality tennis and he played very well after his serve. I didn’t make him defend enough. I just gave him enough time to really dictate the play from back of the court and he deserved to win.”

Novak Djokovic looks downcast during his defeat by Stefanos Tsitsipas
Novak Djokovic looks downcast during his defeat by Stefanos Tsitsipas (Andy Wong/AP)

In the last four, Tsitsipas will try to claim a first win over third seed Daniil Medvedev, who defeated Fabio Fognini 6-3 7-6 (4).

Zverev will take on 11th seed Matteo Berrettini, who boosted his hopes of appearing at the O2 Arena by knocking out fourth seed Dominic Thiem 7-6 (8) 6-4.