Roger Federer was not going to go gently, of course, no matter how daunting the number of match points — his opponent accumulated seven! — no matter how achy his 38-year-old legs, no matter how slow his serves, no matter how off-target his groundstrokes.

Federer still plays for the love of these stages and circumstances. Still yearns for more trophies, too. Down to his very last gasp, time and again, against someone a decade younger, 100th-ranked Tennys Sandgren of the United States, Federer somehow pulled off a memorable comeback to reach the Australian Open semifinals for the 15th time.

Despite all sorts of signs he was not quite himself for much of the match, Federer beat the biceps-baring, hard-hitting, court-covering Sandgren 6-3, 2-6, 2-6, 7-6 (8), 6-3 on Tuesday in a rollicking quarterfinal that appeared to be over long before it truly was.

“For the most time there, I thought that was it. Of course, there's little sparkles where maybe not. Then you're like, ‘No, it IS over,’” said Federer, who only once before had won after facing as many as seven match points, equaling his personal best from all the way back in 2003. “Only maybe when I won that fourth set did I really think that, maybe, this whole thing could turn around.”

He said afterward that it had been his groin muscle that was the problem and he couldn't be certain whether he would be fully recovered for his next match. That will come against defending champion Novak Djokovic, who overwhelmed No. 32 Milos Raonic 6-4, 6-3, 7-6 (1) to improve to 10-0 against the 2016 Wimbledon runner-up.

“He was just too good,” Raonic said.

It'll be the 50th meeting between No. 3 Federer, who has won 20 Grand Slam titles, and No. 2 Djokovic, who owns 16.

Djokovic leads their head-to-head series 26-23, including their past five matches at majors.

“Roger is Roger. You know that he's always going to play on such a high level, regardless of the surface,” Djokovic said. “He loves to play these kind of matches, big rivalries, semis, finals of Grand Slams.”

About the only thing that slowed Djokovic's progression to a 37th career Grand Slam semifinal — Federer earned his 46th — was the medical timeout the Serb asked for at 4-all in the third set so he could put in new contact lenses.

“It was just something I had to do,” Djokovic said, “because those few games, I really couldn't see much.”

The last two men's quarterfinals are Wednesday: Rafael Nadal vs. Dominic Thiem, and Alexander Zverev vs. Stan Wawrinka.

One women's semifinal was set Tuesday: No. 1 Ash Barty, trying to become the first Australian Open singles champion from the host country since the 1970s, against No. 14 Sofia Kenin, a 21-year-old American never before this far at any major tournament.

Wednesday's quarterfinals are Simona Halep vs. Anett Kontaveit, and Garbiñe Muguruza vs. Anastasia Pavlyuchenkova.

There was a lot to live up to after the drama of Federer vs. Sandgren.

“You can't give a good player — let alone maybe the best player ever — that many chances to come back,” said Sandgren, his voice low, his eyes looking down. “They're going to find their game and start playing well. That seemed to me what happened.”

In truth, so much had happened.

Federer got into a dispute with a line judge and the chair umpire over cursing. He left the court for a medical timeout early in the third set, then was visited by a trainer later for a right leg massage.

Sandgren was run into by a ballkid during a changeover in the tiebreaker; was distracted by a courtside broadcast commentator.

The 28-year-old from Tennessee has never been a major semifinalist and was trying to become the lowest-ranked man in the Australian Open's final four since Patrick McEnroe — John's younger brother — was No. 114 in 1991.

Imagine, then, the heartbreak for Sandgren, who toiled for years on lower-level tours and was so thrilled just to share the stage with Federer.

“Maybe," Sandgren said, "I'll get another look, another shot.”

After rolling through the second and third sets as Federer's serve dropped from an average of 112 mph to 105 mph — “Wasn't popping like it does normally,” Sandgren observed — and Federer's unforced errors totaled 30, the underdog led 5-4 in the fourth set.

That's when Sandgren earned his first trio of opportunities to complete a career-defining victory. But he missed a shot each time. There were four more match points in the tiebreaker at 6-3, 6-4, 6-5 and 7-6.

“Honestly, when they told me seven, I was like, ‘What?!’ I thought it was three,” Federer said. “It's such a blur.”

Djokovic's take on Federer's comeback: “Amazing.”

Raonic's: “Impressive.”

When Sandgren sent an overhead smash long to give Federer the fourth set. Federer quickly controlled the fifth and ended the victory with a service winner at 119 mph, a little more than an hour after first staring down defeat.

“Just seemed like his level picked up when his back was right up against the wall,” said Sandgren, who only got the chance to serve on one of those seven pivotal points. “He just wouldn't give me anything.”

That's how Djokovic makes foes feel.

The key moment for him Tuesday came rather early: Raonic went into the quarterfinals having won all 59 of his service games in the tournament. But that streak ended at 5-4 against Djokovic. On Djokovic's ninth break point of the match, Raonic missed a forehand to cap a 19-shot exchange, handing over the opening set.

Djokovic yelled and threw an uppercut. Two Raonic service games later, he broke yet again, all he would need to own the second set, too. Soon enough, he was two wins from a record-extending eighth championship at the Australian Open.

Federer has won six titles at Melbourne Park and never lost there to anyone ranked worse than 54th. But Sandgren, whose career tour-level record is under .500, played superbly. He won more points, 161-160, and produced edges of 27-5 in aces, 73-44 in total winners.

“I mean, he never gives up,” Djokovic said about Federer. “When it matters the most, he's focused and he plays his best tennis.”

Federer knows exactly the sort of pain Sandgren experienced.

Last July, Federer failed to convert a pair of championship points in the fifth set of the Wimbledon final before losing to Djokovic.

“These ones just sting, and they hurt," Federer said. “But ... I was incredibly lucky today.”