Roger Federer defied age and logic once again to save seven match points before beating unseeded American Tennys Sandgren in a sensational Australian Open quarter-final.
The out-of-sorts Swiss fought off form and fitness concerns before winning 6-3 2-6 2-6 7-6 (10-8) 6-3.
World number 100 Sandgren looked set to be the lowest ranked player to reach the Melbourne semi-finals since 1991.
But third seed Federer battled to win in three hours and 28 minutes.
The 20-time Grand Slam champion, who had a medical timeout in the third set for a groin problem, will play Serbia's defending champion Novak Djokovic or Canadian 32nd seed Milos Raonic in the last four.
Federer calmly raised his racquet in the air, taking the acclaim of a buzzing crowd on Rod Laver Arena, after Sandgren dumped a forehand into the net on the Swiss' first match point.
The fatigued pair shook hands at the net, Sandgren wishing his rival luck before trudging off to a standing ovation from the 15,000 fans barely able to believe what they had seen.
"You've got to get lucky sometimes I tell you that," Federer said. "Sometimes you're not under control.
"I just hoped he wouldn't smash a winner, just keep the ball in play and if he does miss one of two then see what is going through his mind.
"As the match went on I felt better and the pressure went away.
"I didn't deserve this one but I'm standing here and I'm obviously very happy."
With 38-year-old Federer well into the twilight of his career, he has to carefully manage his workload to preserve himself for the things which matter most: the Grand Slams.
And that appears to have worked in his favour as he came through another gruelling match at Melbourne Park after being on the brink of defeat.
Federer had not played since the ATP Finals in November, save for a few exhibitions in Central and South America, and has been helped by a favourable draw at Melbourne Park.
All four of his matches have been against unseeded players, although they did not all prove to be as straightforward as he would have hoped.
Only a fightback from 8-4 in the 10-point match tie-break against Australian John Millman stopped him falling in the third round.
In the next round he was pushed by Hungary's Marton Fucsovics before winning in four.
Again he was a shadow of himself for most of the contest against Sandgren before rediscovering his best form when it mattered most.
After a fairly routine opening set, Federer's level dipped considerably as his unforced error count more than doubled in the second and mistakes continued to fly off his racquet in the third where he had treatment for a groin injury when trailing 3-0.
His serve speeds slowed considerably and he walked gingerly to his chair at the changeovers.
The six-time champion - and the pro-Federer crowd - became increasingly edgy. Sandgren grew in confidence.
But once Federer overcame his injury, he improved considerably in the fourth and dominated in the fifth to earn another memorable victory.
"My groin and leg started to tighten and I struggled in defence," said Federer who has never retired during a career which has seen him play 1,512 matches.
"I don't like to call the trainer because it is a sign of weakness. The best thing with the groin is you go off court and people don't know what it is.
"I believe in miracles, there could be rain, there could be other stuff. It wasn't bad enough where thought it would get worse, just sore.
BDST: 1700 HRS, JAN 28, 2020