Roger Federer prevailed 6-4 3-6 6-1 3-6 6-3 after a rollercoaster ride of a 35th chapter of his rivalry with Rafa Nadal to win his fifth Australian Open and clinch a first grand slam title in four and a half years on Sunday.

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 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.

But he was finally able to celebrate with tears in his eyes after coming out on top after three hours and 38 minutes of enthralling tennis to become the first man to win five or more titles at three different grand slams.

“There are no draws in tennis but I would have been happy to share one with Rafa tonight,” he said.

“I wasn’t sure if I was going to make it. I hope to see you next year and if not it’s been a wonderful run here.”

Nadal, the 2009 champion, was typically gracious after losing his third Melbourne final and coming up short in his bid for a 15th grand slam title.

“Congrats to Roger, just amazing the way he’s playing after so long away from the tour,” the 30-year-old said.

“It’s been a great month for me; I worked a lot to get where I am today. It was a great match and I think Roger probably deserved it a little more than me. I will keep on fighting.”

Federer made the slower start to the contest with Nadal drawing him into lengthy rallies and targeting his backhand.

It was the Swiss who made the first breakthrough, though, 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 Nadal was all over his opponent’s serve at the start of the second with two Federer backhands into the net giving the Spaniard 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 Spanish 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 in a 10-minute game at the start of the third.

>

The momentum had swung, though, and Federer stepped up a gear with some brilliant shot-making allowing him to rattle off the next two games and 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, saved a couple of break points to secure 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 when Federer netted a backhand volley and held under unrelenting 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 on his first grand slam since the 2012 Wimbledon tournament easily and put the set back on serve at 3-3 when Nadal sent a rasping forehand centimetres wide on his sixth break point.

He needed another five break points on Nadal’s next service game before the Spaniard finally cracked and Nadal was still battling away when Federer finally sealed the deal.