The 36-year-old was made to work hard but eventually overcame his opponent 6-7 6-4 6-3, making amends for two final defeats to the Argentine in Basel in 2012 and 2013.
In a tight opening set, Federer had the chance to take it on serve, only for Del Potro to break, and the Swiss veteran went on to lose five points in a row to surrender the tie-break.
Federer saved a break point at the start of the second but found himself thumping the net with his racquet in frustration as he missed a routine backhand volley on break point.
However, the 19-time Grand Slam champion regained his composure to break in the final game of the set, before wrapping up the victory with two further breaks in the third for the eighth Swiss Indoors crown of his career.
After the match, Federer confirmed that he would be pulling out of next week's Paris Masters, to all but ending his chances of taking the year-end world number one spot from Rafael Nadal.