The 35-year-old capped his triumphant return from knee surgery with a record-extending 18th major title after a vintage battle with his Spanish rival, who had won all three of their previous meetings at Melbourne Park.
Lefthander Nadal, also returning from injury this year, showed sustained periods of his brutal best from the baseline but was just unable to stay with his rival in the gut-wrenching drama of the deciding set.
Federer was forced to endure a nervous wait for his victory after Nadal unsuccessfully challenged the line call on the second championship point before becoming the first man to win five or more titles at three different grand slams.
The Swiss, for many the greatest player of all time, celebrated with tears in his eyes but his first words were for his old friend and rival.
“Tennis is a tough sport, there are no draws in tennis but I would have been happy to accept one tonight and share it with Rafa,” he said.
“I would have been happy to lose to be honest, the comeback was as good as it was. I hope to see you next year but if not, then it was a wonderful year here and I couldn’t be happier tonight.”
Nadal, the 2009 champion, was also typically gracious after losing his third Melbourne final and coming up short in his bid for a 15th grand slam title.
“It was a great match and I think Roger probably deserved it a little more than me,” the 30-year-old said.
“I played a great quality of tennis. That’s great news for me. I believe that if I have my body in the right condition, I can have a great year.”
Federer made the slower start to the contest but it was the Swiss who made the first breakthrough, converting the first break point of the match with a forehand winner to go 5-4 up.
That was enough to take the opening set but this was never going to be a straightforward win for either player and Nadal was all over his opponent’s serve at the start of the second and grabbed a 2-0 lead.
Federer had two break points in the next game but Nadal fought them off and then broke again as his rival struggled for accuracy under the Spaniard’s onslaught.
Four big forehands gave the Swiss a break back but Nadal held firm to serve out the set and Federer needed three aces to save three break points at the start of the third.
The momentum had swung, though, and Federer stepped up a gear and rattled off the next two games with Nadal left scrambling to fend off a second break in a marathon fourth game.
He was unable to repeat the feat in the sixth game and Federer, his crosscourt backhand causing Nadal all sorts of problems, secured a two sets to one lead with a drop volley.
The pendulum had not finished swinging yet, however, and Nadal broke for 3-1 in the fourth and held under huge pressure in the next game with a brilliant crosscourt forehand winner at full stretch.
Nadal again closed out the set and Federer took a medical timeout before the start of the decider, returning to court only to give up his first service game.
Federer was not prepared to give up easily on a first grand slam title since Wimbledon in 2012, though, and upped his aggression to put the set back on serve at 3-3 when Nadal sent a rasping forehand wide.
He needed another five break points on Nadal’s next service game before the Spaniard finally cracked as Federer sealed the title with a forehand winner that Hawk-Eye confirmed hit the line.
“In the fifth set, I didn’t win one serve easily. Even if I played great in the break points, I was suffering a lot,” said Nadal.
“He probably remained a little bit more free on points on my serve. That’s what I needed in that moment, and I didn’t have.”
With Federer’s contemporary Serena Williams having won the women’s title for the seventh time on Saturday, the 2017 Australian Open is destined be remembered as the retro slam.
Federer gave a reminder that no one is immune to the ravages of time, however.
“Now it’s time to celebrate in a massive way,” he said. “(But) at 35 years old, I don’t like to say it, but I’m so old and so the body hurts, it aches.”
(Reporting by Nick Mulvenney, editing by Toby Davis)