Roger Federer maintained his 100% record at this year's ATP World Tour Finals and ended Kei Nishikori's hopes with a three-set win in London.
The Swiss six-time champion came through 7-5 4-6 6-4 to claim his third round-robin victory at the O2 Arena.
Federer, 34, had already won the group and will be joined in the semis by Novak Djokovic or Tomas Berdych.
The Swiss had qualified with victory over world number one Djokovic on Tuesday, but Nishikori still had a chance to progress and pushed the third seed to the limit in a match he did not need to win.
He was broken twice in a row in the first set but prevailed in game 12 after some fabulous play around the net from both men, and then opened up a 4-1 lead in the second.
Nishikori's day was not done, however, as the Japanese 25-year-old hit back with five games in a row to level after one snatched Federer forehand that must be among the worst he has ever hit.