Roger Federer has claimed a record-tying fifth ATP Indian Wells Masters title, continuing his career resurgence with a 6-4, 7-5 victory over Stan Wawrinka.

Federer, sidelined some six months after knee surgery last year, returned to win his 18th Grand Slam title at the Australian Open in January.

With Sunday’s triumph in the all-Swiss final, Federer joined Novak Djokovic as the only men to win five Indian Wells titles, adding to those he won in 2004, 2005, 2006 and 2012.

At 35, Federer is the oldest ATP player to win one of the elite Masters titles, supplanting Andre Agassi, who was 34 when he won in Cincinnati in 2004.

While Federer had won 19 of 22 prior meetings with Wawrinka, he noted that his compatriot would be no easy mark as he played his first tournament in America since winning the US Open in September.

But Federer claimed a tightly contested first set with a break in the 10th game, pushing Wawrinka into a forehand error to end a tense rally for a set point, on which Wawrinka sent another forehand long.

Wawrinka responded immediately with a break to open the first set — after Federer had held all 42 of his service games in the tournament to that point.

He had saved the lone break point he faced against Rafael Nadal in the fourth round, but sent a backhand long on break point to give Wawrinka the advantage in the set.

Wawrinka then withstood two break points to hold for a 2-0 lead, which proved short-lived as Federer won the next three games to take a 3-2 lead.

Finally Wawrinka found himself serving to save the match. A backhand into the net gave Federer a chance, and he seized it with a volley winner.

Wawrinka broke down in tears as he accepted the runner-up trophy, creating a touching moment with Federer which the crowd lapped up.

“I’m sorry, I’m just tired after 10 days. I’m sorry. I would like to congratulate Roger. He’s laughing, he’s an a–hole,” said Wawrinka, to huge applause.

“I’ve lost some tough ones against you, but when you played the final in Australia, I was still your biggest fan. So congratulations on your comeback and congratulations on today.”

Federer said he was only trying to cheer up Wawrinka. “I was trying, when he looked at me, not to give him the sad face,” Federer said. “I was looking at him going, ‘You’ll be fine,’ and gave him a laugh, say, maybe gets his mind off it. I guess I achieved that.”

Asked later if it was the first time that he had been called the expletive, Federer said he’d heard it “many, many times before” in a joking way. “That’s why I take it as a compliment,” he said, smiling. “There’s not always cameras around, so I get called that sometimes. Quite often, actually. On the court is the first time, but it felt good.”

Federer will climb four spots to world No. 6. “I have totally exceeded my expectations. My goal was to be top eight by Wimbledon. This is just a dream start,” Federer told Sky Sports courtside.

“I understand the talk about [me getting back to] world No. 1 with Andy [Murray] and Novak [Djokovic] not playing well, and I’ll try to back it up. But this is my 90th [tour-level] title, so I’ll try to enjoy this first.”