The stakes were simple heading into the match; whoever won the clash progressed to the semi-finals alongside Novak Djokovic, the Serb having already won Group B no matter the result of his clash against Richard Gasquet later on Saturday.
And for a set and a half that looked like being Del Potro before Federer somehow found a way to turn the match around and force the final set.
The Argentine will head into the off-season ruing what might have been, as he also squandered an early break lead in the decider before Federer wrapped up the match at the first attempt with a booming ace.
Del Potro broke Federer in the first game of the match before racing into a 5-1 lead but Federer settled to play some scintillating tennis. It was in vain, however, as the Argentine took the honours 6-4.
Del Potro then broke his opponent in the third game of the second before the Swiss got a break-back in the sixth and the set went with serve until the Swiss took the tie-break 7-2.
The Swiss then lost first service game of the decider but managed to break-back in the fifth game before playing the better tennis and was rewarded in the 10th game of the set with another break.
Federer punched an inside-out forehand across court to sneak ahead against the Del Potro serve before the Argentine conceded the game with back-to-back forehands long.
The Swiss world number seven made a nervy start to serving out the match, a couple of netted forehands giving Del Potro a sliver of hope of securing the break back. But a brutal forehand down the line set up an easy smash to bring up the first match point before Federer closed things out at the first time of asking with his 10th ace of the day.
The victory set up an incredible 32nd meeting with Rafael Nadal in Sunday’s semi-finals while Djokovic will face Group A runner-up Stanislas Wawrinka.