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-time 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% 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 semifinals 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-time 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.
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 semifinals along with India's Rohan Bopanna and his Romanian partner Florin Mergea.