Between meekly losing his opening match against Dominic Thiem and then being constantly reminded this week of one of the most heartbreaking moments of his career, his bitter defeat by Novak Djokovic in the Wimbledon final, Roger Federer had plenty of reason to doubt as he prepared to face Djokovic on Thursday night.

Instead, the 20-times grand slam title winner produced a breathless exhibition of serving and aggression to reach the semi-finals of the ATP Finals with a 6-4, 6-3 win. It ended a four-match losing run against his great rival, his first win since 2015.

“It was a good day for tennis,” Federer said. “I’m sure to some extent, not because I beat Novak but the race for world No 1 was riding on the match, as well, and the atmosphere in the building was very nice. I was able to produce under pressure and I was trying to remind myself to play with less pressure than what Novak had throughout the game, and it worked. I’m very happy. I’m very pleased.”

Djokovic’s thrilling defeat against Thiem on Tuesday meant both men were presented with a more familiar format: win or get lost. As Federer thrived under the pressure, Djokovic looked edgy and nervous, with a double fault twice in a row to open his service game at 1-1. The Swiss pounced, slamming two crosscourt backhands in successive points to break.

Throughout the first set Federer produced one of his best serving sets of the year, firing eight aces and landing 19 of 23 first serves on the ballistic, low bouncing courts of the O2 Arena. He stared down the best returner in the world yet relinquished only three points on his serve.

“The serve stats are clearly key to either hang with him or beat him,” Federer said. “I did that in Paris. I did that in Wimbledon. Actually, I hardly got broken in those matches, too, and again tonight. So against Novak it seems to work well on my serve. It’s just a matter of sometimes having better returning days.”

Most aggression against Djokovic provokes a brisk response. He began to land penetrating, deep returns early in set two and quickly generated a break point at 2-1. But no moment underlined Federer’s readiness quite like the way he scuppered the danger with an incredible forehand down the line on the back foot, finishing the break point with an assured volley winner.

Novak Djokovic was outclassed on the day. Photograph: TPN/Getty Images

As Federer resisted, Djokovic’s shoulders hunched over and his composure crumbled. He grimaced and shook out his surgically repaired elbow a couple of times, but otherwise he offered nothing and already seemed defeated. In the following game at 2-2, he sprayed a forehand long and dumped a backhand into the net to bring up three break points.

In this mood, Federer was not going to let the opportunity slip and he landed the definitive break for 3-2 by forcing a Djokovic error with a penetrating crosscourt forehand. After that he never looked back, finishing with 23 winners and five unforced errors and landing 12 aces in 49 first serves, an ace every four serves.

“He served great, moved well, returned my serve very well,” said Djokovic, whose defeat means Rafael Nadal will end the year as the world No 1. “From his end, I think he did everything right. From my end, I just – you know, I was just playing too neutral. I couldn’t read his serve well. Just a pretty bad match from my side.”

Given Federer’s struggles earlier in the tournament, this is a particularly significant win. No athlete has been described as hyperbolically as Federer has throughout his career. His tennis is always framed balletic, effortless and something alien, often belying the fact that it has taken so much grit and perseverance for him to continually compete at the highest level for so long.

Federer’s initial dominance was crashed by Djokovic and Nadal, who countered his attack with unheard of defence. They now lead their win‑loss records against him and they are swiftly chasing down his records. After dominating so thoroughly during the early years of his career, one of Federer’s greatest achievements has been his acceptance of their success as he continues to persevere on his own path.

Wimbledon seemed like the perfect opportunity to demonstrate the toughness that has allowed his level to endure for so long. But in the end, the story was of how he faltered when faced with the pressure of closing out the victory. But on Thursday night he bounced back from defeat earlier in the week and those bittersweet summer memories to give himself another chance to win his seventh ATP Finals title.

“It’s just a point and shot here and there that makes a difference and he got it [at Wimbledon], so there’s nothing you can do there,” Federer said. “Move on, try harder next time around, hopefully luck goes on your side. I stayed calm, I played great until the very end and I couldn’t be more happy right now.”