Federer, who has won six Australian championships among his 20 major titles, took an off-court medical timeout in the third set and was on the verge of a shocking quarterfinal exit in the fourth before rallying to win 6-3, 2-6, 2-6, 7-6 (8) 6-3.
The 38-year-old Federer will next play either seventh-time Australian Open champion Novak Djokovic or No. 32 Milos Raonic.
A ballkid collided with Tennys Sangren during a changeover in the pivotal fourth-set tiebreaker against Roger Federer in the Australian Open quarterfinals. Sandgren was walking to his court-side seat at 3-3 in the breaker when the ballkid ran along the side of the court and collided with his right calf muscle. The 100th-ranked Sangren told the chair umpire what happened, then stretched his legs and returned to the match. He had four match points in the tiebreaker but Federer rallied to force the match to a fifth set.
Roger Federer has saved seven match points and forced his Australian Open quarterfinal against 100th-ranked Tennys Sandgren to a fifth set. Federer won the first set 6-3 but Sandgren won the next two sets 6-2, 6-2 and had the match points in the fourth before Federer rallied to win it in a tiebreaker 7-6 (8). Federer had an off-court medical timeout after falling behind 3-0 in the third set.
American teenagers Coco Guaff and Caty McNally have lost their Australian Open doubles quarterfinal 6-2, 6-4 to 2018 champions Kristina Mladenovic and Timea Babos.
The 15-year-old Gauff beat 2019 champion Naomi Osaka in the third round of singles before losing to fellow American Sofia Kenin. She went a round further in the doubles.
Second-seeded Mladenovic and Babos won the title here two years ago and lost the final last year.
In other quarterfinals, top-seeded Hsieh Su-wei and Barbora Strycova beat Jennifer Brady and Caroline Dolehide 6-2, 6-2.
Top-ranked Ash Barty is into the semifinals, keeping alive her chances of being the first Australian to win her national championship in 42 years.
Barty beat two-time Wimbledon champion Petra Kvitova 7-6 (6), 6-2 on Rod Laver Arena and will next play Sofia Kenin.
Barty was helped when Kvitova double-faulted on break point in the seventh game of the second set, and Barty held serve in the next after saving two break points. She clinched the match with an ace.
Kenin beat Ons Jabeur in the first quarterfinal earlier on the same court.
The last Australian to win the national title was Chris O'Neil in 1978.
Next up on Rod Laver Arena is a men's quarterfinal between Roger Federer and Tennys Sandgren.
Sofia Kenin is the first player into the Australian Open semifinals. The 21-year-old American beat Ons Jabeur 6-4, 6-4 in the first match of the day on Rod Laver Arena to reach the semifinals at a major for the first time.
Kenin's best run at a major was to the fourth round at last year's French Open.
She beat 15-year-old Coco Gauff in the fourth round, when she made only nine unforced errors in winning the second and third sets.
Against Jabeur, Kenin made the key break in the second set in the seventh game after saving three break points of her own in the previous game.
Jabeur was the first Arab woman to make the quarterfinals at a major.
Next up on Rod Laver Arena is another women's quarterfinal between top-ranked and French Open champion Ash Barty and two-time Wimbledon winner Petra Kvitova.
More AP Tennis: https://apnews.com/apf-Tennis and https://twitter.com/AP_Sports