Roger Federer beat fellow Swiss Stan Wawrinka 7-5 6-3 1-6 4-6 6-3 to reach the Australian Open final and stay on course for an 18th Grand Slam title.
The 35-year-old will face Rafael Nadal on Sunday if the Spaniard beats Grigor Dimitrov in Friday’s semi-final.
The Swiss, returning from a six-month lay-off to rest his left knee, last won a major at Wimbledon in 2012.
He is the oldest man to reach a Grand Slam final since Ken Rosewall did so at the 1974 US Open at the age of 39.
«I couldn’t be happier right now,» said Federer. «I felt like everything happened so quickly at the end, I had to check the score.
«I never ever in my wildest dreams thought I’d come this far in Australia. It’s beautiful, I’m so happy. »
Federer’s extraordinary run in Melbourne had already seen him beat top-10 seeds Tomas Berdych and Kei Nishikori to reach the last four.
Seeded 17th following his injury, Federer had an 18-3 record against the fourth seed and reigning US Open champion coming into the semi-final, but the two had never played a five-set match.
Both players needed medical treatment during a match of high intensity but it was the 17-time Grand Slam winner who finally prevailed after three hours and five minutes.
Federer will now seek a fifth Australian Open title, and his first in Melbourne since 2010, when he plays in his 28th Grand Slam final and 100th Australian Open match on Sunday.
What makes Federer’s run to the final remarkable is the combination of being in the twilight of his career and not having played competitively since his Wimbledon semi-final exit last year.
Federer missed the Olympic Games and the rest of the 2016 season to have «more extensive rehabilitation» on a knee injury suffered in February while he ran a bath for his twin daughters.
He played just seven tour events last year, leading to him dropping out of the world’s top 10 for the first time in over 14 years.
After beginning his comeback with victories against Britain’s Dan Evans and France’s Richard Gasquet in the Hopman Cup — a non-ranked event played in the first week of January — Federer played down his chances of going far in the Australian Open.
But, after reaching his first Slam final since the 2015 US Open, he finally spoke about the prospect of winning in Melbourne.
«I can really actually talk about playing a final — I’ve been dodging that bullet for a few rounds,» he said.
«I’ll leave it all out here in Australia and if I can’t walk for five months that’s OK. »
Wawrinka noted how the tour and the fans had missed Federer, saying: «Everyone wants even more to see him play, to see him win. He’s flying on the court. He’s playing amazing tennis. He’s the best player ever. »
Former world number one Federer started the match brightly and had three early break points before converting his first set point, on Wawrinka’s serve, in the 12th game.
Wawrinka, the 2014 Australian Open champion, was broken for the second time at 2-3 in the second set as Federer maintained his impressive standards.
Clearly frustrated, the 31-year-old Wawrinka cracked his racquet in two over his left knee and, after the set, left the court with a trainer for treatment to his other knee.
But he came back superbly to win the third set in 26 minutes and break Federer in the ninth game of the fourth set to take the match to a decider.
Federer went off for a lengthy medical timeout for treatment to his leg as the physical nature of the match started to tell.
He also came back fighting and broke Wawrinka in the sixth game when the US Open champion double-faulted on break point.
There was no let-up as Federer completed a stunning victory to the delight of the majority of fans in Rod Laver Arena.
Federer explained why, after losing the fourth set, he left the arena to take his injury timeout.
«I have had a leg thing going on for a week and felt it from the second game on in the match,» he said.
«If you go off the court, that means the treatment is further up the leg.
«I never take injury timeouts. Stan took his, so I thought people won’t be mad — Stan won’t be mad hopefully.
«You hope something works, and that the physio has some magic hands going on. »
If 14-time major winner Nadal wins his semi-final the pair would contest their ninth Grand Slam final together and their first since the French Open in 2011, when Nadal won in four sets.
«Rafa has presented me with the biggest challenge in the game,» Federer said when asked about the prospect.
«I’m his number one fan. His game is tremendous. He’s an incredible competitor.
«I’m happy we had some epic battles over the years and of course it would be unreal to play here. I think both of us would never have thought we would be here playing in the final. »
BBC tennis correspondent Russell Fuller:
Australia Day was graced by two remarkable achievements by two remarkable players in their mid-thirties.
One, Roger Federer, has spent six months out of the game after knee surgery, and the other, Venus Williams, has lived for many years with an auto-immune disorder which causes fatigue and joint pain.
Federer had to win a deciding set against one of the toughest men on the block. The extraordinary defence he produced when Wawrinka hammered a forehand towards him on break point early in the fifth set turned out to be worth its weight in gold.
Yes, Mischa Zverev did him a favour by taking out Andy Murray, but Federer has now beaten Wawrinka, Nishikori and Berdych — with two of those matches going the distance.