0920 GMT June 23, 2018
The 36-year-old Swiss, making his 15th appearance at the season-ending event for the top eight players in the world, won 6-4, 7-6 (7-4) at the O2 Arena, BBC reported.
Federer served out the opener after 36 minutes but could not close it out in the second as five break points slipped by across the seventh, ninth and 11th games.
For the first time in four meetings. Sock managed to take the 19-time Grand Slam champion to a tie-break, but a double fault from the American at 4-5 handed Federer a match point that he clinically converted.
"I got off to a great start, my big hope was I was going to be able to play a bit more freely after that," said Federer.
"The second set was tight, I missed some opportunities, the breaker could have gone either way and in the end he helped me with some double faults and some mistakes.
"I'm really happy that I got through somehow."
Federer last won the season-ending title back in 2011, but he is the favorite to add a seventh victory to his extraordinary CV at the end of a year when he has won two more Grand Slam titles.
It is a far cry from 12 months ago, when the Swiss was absent through injury, while Murray and Djokovic – themselves missing this year –battled for the year-end number one ranking.
"It's wonderful to be back, especially after missing last year with injury," said Federer.
"It was tough not to be here but at the same time I really enjoyed the battle for number one between Andy and Novak."
Nadal, 31, has had a similarly spectacular return to form in 2017, winning the other two major titles and ending the year as world number one.
German bounces back
Alexander Zverev beat Marin Cilic 6-4, 3-6, 6-4 in Sunday's second round-robin match in the Boris Becker Group.
German third seed Zverev broke serve in the opening game with a deft volley and took the first set, but Croatian fifth seed Cilic grew stronger as the match progressed and looked set for victory at 3-1 up in the decider.
However, 20-year-old Zverev showed why he has won two Masters titles this year as he reeled off five of six games, breaking serve to love to clinch victory.
"For the most part of the second and third sets he was the better player, I was just happy to come back and get the win," said Zverev.
Defending champion Andy Murray, five-time winner Novak Djokovic and three-time Grand Slam champion Stan Wawrinka are among a number of players who chose to end their seasons early to recover from injuries.