The 36-year-old fought back from a set down to win the 95th ATP title of his career, taking him clear above Ivan Lendl into second on the all-time list behind Jimmy Connors' mark of 109.
It was Federer's first success against the Argentine in a Basel final, after the South American beat him in both 2012 and 2013.
Federer's victory would have boosted his hopes of taking the world number one spot from Rafael Nadal, however following his win the Swiss pulled out of next week's Paris Masters, virtually ensuring his old rival will end 2017 on top of the world rankings.
“My body is asking for a break,” said the Swiss legend. “Basel takes a lot out of me emotionally. I had five matches in six days. I feel sorry and sad for Paris.
“I love to play at Bercy, it's a few times now that I've not played there. It's a tough one but they have to understand that it's for the cause of staying injury-free and healthy.
“I'd like to be fully fit for London (the World Tour Finals) and for 2018.”
The 19-time Grand Slam champion has now won a Tour-leading seven titles this season after beating Nadal in the Shanghai Masters final a fortnight ago.
“Congratulations to Juan Martin,” Federer said after his win in Basel. “You've had a great run since the US Open [when he beat Federer in the quarterfinals] and before.
“I wish that I was able to play every week like you have, it's going to be difficult for me in the future to do that.”
Del Potro will be playing for a fourth successive week in Paris after coming back earlier in the season from wrist problems, as he looks to snatch a late place for the eight-man event in London.
The 29-year-old reached the Shanghai semifinals and won in Stockholm earlier this month before his run in Basel.
Federer lost only two sets during the week as he improved his head-to-head record to 17-6 over del Potro, with a third win in four matches against the former US Open champion in 2017.
“It's unbelievable how well Roger is playing,” said del Potro. “I hope to be in such shape when I'm his age. But I doubt I will be.”
Federer now stands 49-4 overall this season.
The pair traded breaks in the opening two games, with an epic first set finally finding its way to a tie-break.
Federer took a 3-0 lead but had no answer as del Potro won six straight points.
The top seed saved two set points but went down on the third.
The world number two battled hard in the second set, breaking in the final game to level the match as del Potro returned long.
Federer broke for 3-1 in the decider and five games later put a forehand winner into the corner to bring up three match points.
Del Potro saved the first but returned long as Federer wrapped up victory after two and a half hours of play.
“Roger was there playing high-level tennis for two and a half hours,” said del Potro. “He was better in key moments and he won.
“He returned well and broke me playing good tennis. I have little things to improve and I can learn from this match.
“Physically I was 100 percent today, I was close to winning, my body did not affect me in the final. I was running for all three sets and I fought until the last point.”