Two of the three sets went to tie-breaks with the towering Argentine eventually winning 6-4 6-7 7-6 to claim his second title in as many weeks following his win in Vienna one week ago.
The two were meeting for the first time since their epic Olympic Games semi-final when Federer eventually won in a 36-game final set.
There was no quarter given this time, either, in a match featuring long baseline rallies and with Del Potro managing the only service break in the fifth game of the first set.
Del Potro pipped the hometown favourite in a third set tie-break to deny him a 77th ATP Tour title with what was an inspired performance on the indoor surface.
The 31-year-old Federer was contesting the final of the Swiss Indoors for the ninth time, but he was unable to secure his seventh Tour title of the season.