LONDON (Reuters) - Roger Federer's enduring brilliance and his sheer hatred of losing allowed him to withstand a stunning fightback by Kei Nishikori and remain undefeated at the ATP World Tour Finals on Thursday.
The 34-year-old Swiss maestro was on auto-pilot when he led 4-1 in the second set, having snatched an absorbing opener, but needed every shot in his formidable armoury to eventually claw out a 7-5 4-6 6-4 victory.
Japan's Nishikori had looked the more likely winner after reeling off five consecutive games to take the six-times former champion into a deciding set, but his stirring efforts proved in vain as Federer squeezed home.
Federer topped Stan Smith Group with a 100 percent record -- the ninth time in 14 consecutive appearances at the elite event he has won all three of his round-robin matches.
World number one Novak Djokovic, beaten emphatically by Federer on Tuesday, joined the Swiss in the semi-finals when he beat Tomas Berdych 6-3 7-5 in the evening match at the O2 Arena.
The Serb, bidding for a fourth straight title at the season-ender, could have qualified with a three-set defeat, but took no chances in a businesslike display to finish runner up in the group and set up a clash with a resurgent Rafael Nadal.
Federer will play either Andy Murray or Stanislas Wawrinka who complete the round-robin matches in the Ilie Nastase group on Friday.
Nishikori bowed out, having only managed to beat Berdych, but he got a ringing endorsement from the 34-year-old Federer.
"It's amazing what he's able to produce on the court. Today was another showcase of that, how he's able to return second serves, staying on top of the baseline...drilling forehands and backhands up the line. It was impressive," Federer said of the 2014 U.S. Open champion.
Seventeen-times grand slam champion Federer had already sealed a semi-final spot before walking on court on Thursday, but there was never a chance of him letting up.
He jumped into a 3-1 lead before 26-year-old Nishikori began striking the ball with real venom, breaking twice in a row.
Federer squared the set at 4-4 with some rock-solid baseline play wearing down Nishikori.
Nishikori had a point to set up a tiebreak at 5-6 but after a superb cat-and-mouse rally, Federer threaded a backhand down the line. Federer pounced on set point, forcing an error.
Federer was in full flow in the second set, leading 4-1, but Nishikori refused to slink away quietly and took the next five games with some delightful shot-making.
His crucial break at 4-4 came courtesy of an ugly forehand swipe from Federer who hit the ball several metres out with the court at his mercy.
Federer looked tired and tetchy early in the third, even offering an expletive, but crucially hung in from 0-40 down to hold serve, before breaking to move 4-1 ahead.
Again Nishikori stormed back to 4-4, but this time Federer steadied down, found four first serves in the nick of time, then broke for the match with a winning smash.
With a maximum of two matches left in a season which has already brought six titles, Federer said he is in the mood to go out on a high.
"I've got the perfect schedule. I'm off before the semis, which is huge. Now you're looking at potentially a maximum of two more matches and the season's over then," he said.
"It's going to be tough in the sense to win. But for the body, I'm in an ideal situation looking at the semi-final."
In doubles action defending champions and top seeds Bob and Mike Bryan saved five match points against Jamie Murray and John Peers -- 6-7(5) 7-6(5) 16-14 to scrape into the semi-finals.
Reporting by Martyn Herman, editing by Alan Baldwin