LONDON -- Juan Martin del Potro clinched the last spot in the semifinals of the ATP finals on Saturday, beating Roger Federer 7-6 (3), 4-6, 6-3 in their final round-robin match.

Federer, the two-time defending champion, had his first loss in the indoor tournament since 2009. With two wins, Federer had already qualified for the semifinal of the season-ending event that features the top eight players.

Del Potro's win leaves David Ferrer and Janko Tipsarevic with nothing but prize money to play for in their final group-stage match However, the result will decide whether Federer or Del Potro finishes atop Group B and impact the semifinal matchups.

The winner of the group will face Andy Murray on Sunday, while the second-place finisher has to take on top-ranked Novak Djokovic.

Del Potro, who also defeated Federer in the final in Basel last month, converted his only break point of the match in the opening game of the deciding set and held his own serve comfortably to wrap up the win at London's O2 Arena.

He converted his first match point with a forehand passing shot that Federer could only return into the net with a lunging backhand volley.

Federer failed to convert three break points when leading 4-3, and Del Potro eventually held serve after a call on the same shot was overturned twice.

A backhand from Federer was called wide by the line judge, only for chair umpire Lars Graff to declare that the ball was in. Del Potro then challenged Graff's correction, and a Hawk-Eye replay showed that the ball just missed the line.

Federer, who had never looked threatened on his serve, then committed a series of uncharacteristic mistakes in the tiebreaker as Del Potro won six straight points to take a 6-1 lead. He converted his third break point when Federer's backhand return sailed wide.

Federer broke the Argentine to start the second set and lost just five points on his serve the rest of the way to tie the match.

But in the third set, Del Potro broke in the first game and Federer couldn't muster another comeback.