Federer left the court midway through the third set – when he was trailing 3-0 – for a medical timeout for what he confirmed was a groin complaint.
“I don’t know if you can call it an injury, it’s just pain and problems and I need to figure it out now,” he said.
“Two good nights of sleep and doctors and physios and hopefully we’ll find out that it’s actually nothing bad, that it’s just a groin that went really tight. I’m hopeful but we’ll find out.”
He lost the set 6-2 and then saved four match points serving at 4-5 and three more in the tie-breaker in the fourth set to somehow stay alive and force the contest to a deciding set.
His opponent – clearly mentally rattled from having so many match points stolen from him – then lost his way and Federer’s class shone through.
“I think I got incredibly lucky today,” the Swiss champion told the crowd after the match.
“I was just hoping that maybe he was not going to smash the winner on that one point.
“As the match went on I started to feel better again, all the pressure went away and I just tried to play.
“I don’t deserve this one but I’m standing here and I’m obviously very, very happy.”
His groin complaint wasn’t the only thing that Federer had to deal with.
Earlier in the third set, Federer took issue when a lineswoman told the chair umpire that he had sworn loudly after missing a groundstroke.
After receiving a code violation for obscene language from chair umpire Marijana Veljovic, Federer firstly approach her and then went to the back of the court to confront the lineswoman.
It wasn’t something the Australian crowd was used to seeing from the revered Federer and the majority of those in Rod Laver Arena appeared stunned.
But late in the fourth set, the tables turned and it was Sandgren’s turn to deal with the unexpected.
Not only did he have to mentally rid himself of losing four match points, but at the change of ends in the tie-breaker, he was injured when a ball girl ran across the back of his legs, kneeing him in the calf.
“I just bruised my leg,” he said up to the chair umpire, taking another 30 seconds to stretch it out.
He pushed on to create three more match points – one on his serve – but Federer made him earn every point and Sandgren couldn’t put the final ball away.
Federer, now the oldest man to reach the semi-finals at a grand slam since Jimmy Connors at the 1991 US Open, will play the winner of world No.2 Novak Djokovic and big-serving Canadian Milos Raonic.
The win also makes it 102 at Melbourne Park for Federer, surpassing Wimbledon and ensuring he has won more matches at the Australian Open than any other grand slam.
Sam McClure won the Clinton Grybas rising star award at the AFL media association awards in 2015.