The six-time winner, beaten in his opening round-robin match by Dominic Thiem, needed a victory over eighth-ranked Italian Berrettini to keep alive his hopes of reaching the semi-finals.
Federer got the job done without too much fuss and will now face great rival Novak Djokovic on Thursday as he bids to reach the last four.
The 38-year-old Swiss said: "It's unusual to lose and come back and play again but I did it last year, I had that experience, and I'm happy with how I played today.
"Matteo was always going to be tough with his big serve. To get that break at the start of the second set was key, and I was pretty clean on my own serve.
"Hopefully I can keep that up and play a bit better in my next match."
The task facing debutant Berrettini was daunting, to say the least. Federer has failed to reach the semi-finals at the season-ending tournament only once in 16 previous appearances. He had never been beaten in a second round-robin match and only lost once to a first-timer – a certain Andy Murray in 2008.
Berrettini, meanwhile, had taken just five games off Federer in their only previous meeting, a chastening three-set defeat at Wimbledon earlier this year.
The 23-year-old matched that figure in the first set here and then surpassed it by surviving the only break point at 5-6 to force a tie-break.
However, Federer dropped only two points in the tie-break and broke to love at the start of the second on his way to a 7-6 (2) 6-3 victory.
What the 20-time grand slam winner needs to do in order to qualify against Djokovic – in their first meeting since the Wimbledon final – remains to be seen.
He may need a victory, or to merely win a set against the world number two. What is for certain is that he would like a measure of revenge for July's gut-wrenching five-set defeat at SW19.
Earlier, Britain's Joe Salisbury and American partner Rajeev Ram beat Ivan Dodig and Filip Polasek after a match tie-break to give themselves a chance of reaching the last four.