Roger Federer has had many improbable victories in his career, and a smattering of unusual defeats, but his passage into the semi-finals of the 2020 Australian Open after three-and-half hours of undiluted drama against Tennys Sandgren was in another dimension.

He won 6-3, 2-6, 2-6, 7-6 (8), 6-3 to put the world No 100 away on a warm, sticky afternoon on Rod Laver Arena and set up a semi-final against Novak Djokovic, who later saw off Milos Raonic – but those are the bare bones of the story.

On his way to his second great escape of the week, the six-times winner of this title and owner of a record 20 majors had to save seven match points, received a rare code violation for swearing, snarled at one of the game’s best chair umpires, Marijana Veljovic, then made the most of his luck when Sandgren was within sight of victory and injured his right knee in a collision with a ball girl.

Australian Open day nine: Federer fights back to beat Sandgren, Barty beats Kvitová – as it happened Read more

“Got to get lucky some times, I tell you that,” Federer said courtside. “Those seven match points I wasn’t under control. I was hoping he was not going to smash the winner. He played his match. I got incredibly lucky. As the match went on, I started to play again. I don’t deserve this one, but I’m standing here and I’m very, very happy.”

Commenting on his medical timeout, he said: “I’ve played a lot of tennis. Sometimes you feel a bit funny. I started to feel my groin, my leg was tightening up. I don’t like to get the trainer, show weakness and all that. It wasn’t bad enough it was going to get worse, stiff tight. I don’t even know what time it is. Draws are not getting easier. But you never know. You play without expectations because you know you should probably already be skiing in Switzerland.”

Yet he is in his 46th grand slam semi-final, more than anyone in modern times.

They see-sawed on level terms for the first three frames but the conclusion to the fourth set was excruciating, drawn out like a German opera, one chorus drowning another.

On Friday, Federer came from 4-8 down in the super tie-break to win six points in a row and break John Millman’s heart in the fifth set. Here he was one point from leaving town after two-and-a-half hours. Somehow, he worked his way into a tie-break.

At the changeover on three-all, a ball girl ran into Sandgren and he suffered a bizarre knee twist. Strapped up, he resumed and toughed out a 6-3 lead for three more match points, with Federer serving. Surely he would not be denied again. He found the net with a backhand for 6-4; two chances left. Federer served and saved for 5-6. Sandgren’s destiny was in his hands once more. Federer fashioned parity with a controlled volley. Sandgren got another match point with a big serve down the T. Federer, back on serve, stretched out a long rally, and Sandgren cracked again. Federer smashed a winner, a point from safety.

Facebook Twitter Pinterest Tennys Sandgren fires back against Federer. Photograph: Fred Lee/Getty Images

Sandgren aced for the 24th time and 8-all, then shoved a forehand into the tramlines. Federer served for the set again. Sandgren hit long. Job done.

The fifth was an anti-climax.

At break point in the third game of the third set, Federer was heard to mutter to himself: “Fucking …” The line judge reported it to the chair umpire, and Veljovic gave Federer a code violation for an “audible obscenity”. “What did I say?” Federer inquired on the changeover. “I can’t repeat that,” she said. “You don’t know?” he said. “No, I heard it kind of. But she heard it very clearly.”

Sign up to The Recap, our weekly email of editors’ picks.

While Sandgren looks like someone who has just walked out of a jungle after 40 years, Federer remains the consummate stroller. You know he’s happy with his game when he ambles; if he’s anxious, there is a quickening of the step, perhaps an extra bead of sweat. That was all on show on Tuesday.

After his near-meltdown against Millman, he expected the engine to be purring again. It clunked like an old banger. “The wheels have come off, no doubt about that,” John McEnroe observed when Federer returned from his medical timeout at 6-3, 2-6, 0-3 and serving after an hour and 28 minutes.

The Joy of Six: Roger Federer Read more

Ten times, Federer has come from 0-2 down to prevail. Although he won the first set here, he lost the next two and was broken in the fourth. Four years ago at Wimbledon, Marin Cilic had three match points against him, and Federer came back to win. In 2003, he saved seven match points against the Australian Scott Draper in Cincinnati, and won. This man gets out of jail the way other people get out of bed.

Except he is finding it more difficult to win long matches. He went into the Millman match having lost three five-setters in a row. Now he was red-lining against an opponent who said beforehand: “I tend to lose to guys before I play them. Their record, the amount of matches they’ve played against guys that are top 20, top 10 are silly. I’ve played a lot of tennis in front of very few people. I wasn’t supposed to be here.”

And then he wasn’t. The deciding set was the grind he and everyone else knew it would be. He’d had his shot. Federer, determined not to lose rather than convinced he could win, found some more genius, and willed himself over the line.

But Sandgren left to the biggest round of applause he will ever receive in his life – louder, probably, than if he had beaten the crowd’s perennial favourite.

Facebook Twitter Pinterest Novak Djokovic rarely looked in great danger against Milos Raonic. Photograph: Anadolu Agency/Anadolu Agency via Getty Images

Later, Djokovic looked in assured form as he advanced to a meeting with Federer, beating Raonic 6-4, 6-3, 7-6 (1).

The only real concern for Djokovic came in the third set when he began to experience problems with his contact lens and he took a medical timeout at 4-4.

Djokovic was more than happy with his performance, though, saying: “It felt great on the court, I thought I was very focused,” before turning his attention to another match-up against Federer. “Obviously he’s been one of the all-time greats and definitely one of my two biggest rivals. The match-ups against Roger and Rafa have made me the player I am today.

“I hope to get to at least one match point. It was quite amazing what he has done on the court today. It’s not the first time, that’s why he is who he is. Let the better player win.”

Djokovic also paid an emotional tribute to Kobe Bryant. “He was one of the greatest athletes of all time,” he said, “he inspired myself and many other people around the world. I had that fortune to have a personal relationship with him over the last 10 years.”