MELBOURNE, Australia -- Roger Federer completed the trifecta of throwback-star triumphs on a memorable night at Melbourne Park, holding off compatriot Stan Wawrinka in a wild five-set semifinal.

Coming off a commanding performance in the quarterfinals, Federer was erratic by comparison Thursday. The final score, a 7-5, 6-3, 1-6, 4-6, 6-3 thriller, was full of missed opportunities, mistakes and apparent gamesmanship. Still, the win sent Federer into the Australian Open final for the sixth time, a scenario that just two weeks ago seemed improbable.

"I never, ever, in my wildest dream felt I was going to be coming this far in Australia, and here I am. It's beautiful. I'm so happy," said Federer, who is playing in his first Grand Slam since coming back from six months off due to injury.

Earlier in the day, Venus and Serena Williams advanced to the women's championship, renewing an all-sibling showdown that a decade ago was mainstream at this stage of Grand Slams.

And now Federer, who awaits the winner of Friday's match between No. 9 Rafael Nadal and No. 15 Grigor Dimitrov, has a chance to add to his record 17 Grand Slam titles.

"Regardless of who it's going to be against, it's going to be special either way -- one is going to go for his first Slam, or it's the epic battle with Rafa," Federer said. "All I care about is that I can win. Doesn't matter who's across the net. But I understand the magnitude of the match against Nadal."

Now 35 years old and ranked No. 17 in the world, Federer missed the final six months of 2016 to heal the left knee he injured a day after losing in last year's Australian Open semifinals against Novak Djokovic. Amazingly, Federer improved his hard-court record against Wawrinka, the 2016 US Open winner, to 14-0, a string of excellence in which he has lost only six sets.

Federer is the oldest man to reach a Grand Slam final since Ken Rosewall made the 1974 US Open final at the age of 39.

On Sunday, Federer will have another chance to end a 4½-year drought without a major title. He reflected on the possibility of facing his longtime tormentor Nadal, who leads their career head-to-head record 23-11.

"Rafa's definitely presented the biggest challenge," Federer said. "I played him too many times on clay early in my career, and it affected how I played him on other surfaces. This court allows me to play offense.

"I'm probably his No. 1 fan. His game is tremendous. I'm happy we've had some epic battles over the years."

Roger Federer held off Stan Wawrinka's comeback Thursday and will play for his fifth Australian Open title on Sunday. Clive Brunskill/Getty Images

Unlike the quarterfinals, in which Federer raced off to a 5-0 lead against Mischa Zverev, the four-time Aussie Open champ needed some time to get dialed in. Up 2-1 in the opening set, he had three break chances but failed to convert any. In the ensuing game, Federer fell behind 15-40 -- one of those points an ugly backhand he shanked 5 feet behind the baseline -- but he bailed himself out with two timely unreturnable serves.

Visibly unglued in the second set after falling behind an early break, Wawrinka took his displeasure out on his racket, first blasting it onto the court, then snapping it in half over his knee -- reminiscent of Bo Jackson in the batter's box -- like it was no big deal.

Down two sets, Wawrinka, who was walking gingerly to his changeover chair, took a well-timed break to visit the trainer and have his right knee taped. The downtime inspired Wawrinka. Twenty-six minutes later, he won the third set. Wawrinka then broke Federer twice in the fourth, sending the match into a do-or-die fifth.

Frustrated, Federer left the court to see the trainer, explaining later that it was to treat an upper-leg injury. In the sixth game of the final set, Federer broke Wawrinka when he double-faulted before ultimately ending the 3-hour, 5-minute affair.

"It's hard to stop the bleeding," Federer said. "I was playing tight. It wasn't easy, and Stan was also playing nothing to lose. It was definitely very tricky for us to play our best tennis in the fifth."

The sold-out crowd in Rod Laver Arena roared when Wawrinka double-faulted to give Federer the critical service break.

With Wawrinka out, this marks the first time in 15 years that the men's final won't feature a top-four seed. But no one will be complaining about a lack of star power this weekend.

The Associated Press contributed to this report.