Roger Federer beats Kei Nishikori at ATP World Tour Finals
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.
Top seed Djokovic just needs to take one set off Berdych when they meet at 20:00 GMT.
Federer forced to dig deep
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.
Stat of the match: Federer won just 13 of 43 points behind his second serve
The 17-time Grand Slam champion appeared rattled at 0-40 down early in the third but served his way out of trouble and built another 4-1 lead - only to see Nishikori fight back again.
A double-fault by the eighth seed on game point at 4-5 opened the door for Federer and he converted his first match point with a clinical smash.
"It was extremely difficult," said Federer. "It was a good match, with more breaks than we are used to. Kei is a very good returner, especially on the second serve. It was a very physical match, but I enjoyed it."
For more information go to BBC.com