The evergreen Swiss 37-year-old did not drop a game in a dominant first set but was dragged into an intense battle by an inspired Monfils before prevailing 6-0 4-6 7-6(3).
World number three Federer, playing his first tournament on clay for three years as he prepares for the French Open, surrendered the initiative after his brisk start and was in deep trouble in the third set when he trailed 4-1.
'I don't think his hands are that good' - Zverev coaches Ruud mid-match
Federer struggled with his timing on occasions in breezy, sunny conditions and swatted a ball angrily over the stands when he dropped serve at the start of the decider.
But he broke back in the seventh game with a stunning sliced backhand return.
Monfils earned a match point at 5-6 on the Federer serve with an ice-cool backhand pass, but Federer followed in a second serve and bounced away a smash.
Federer saved another match point to set up a tiebreak and he proved unstoppable as he swept to his 1,200th match win.
Austrian Dominic Thiem awaits in the next round after he beat Italian Fabio Fognini.
"I think Gael did a nice job of not being frustrated losing the first set," Federer said. "I lost five games in a row and it didn't look good for a while but I hung in. There were some highly stressful moments but I mixed it up nicely."
Federer's fellow Swiss Stan Wawrinka, champion at Roland Garros in 2015, continued to produce some vintage form as he beat Japan's Kei Nishikori 6-3 7-6(3).
World number one Novak Djokovic was untroubled as he beat Jeremy Chardy 6-1 7-6(2) to set up a clash against Marin Cilic.
Spaniard Rafael Nadal, who later this month will aim for a 12th French Open, faces American Frances Tiafoe later while defending champion Alexander Zverev plays Hubert Hurkacz.
World number one Djokovic was untroubled as he beat Jeremy Chardy 6-1 7-6(2) to set up a clash against Marin Cilic after the Croatian battled past Serbian Laslo Djere 4-6 6-3 6-2.
Spaniard Nadal, who later this month will aim for a 12th French Open, swept past unseeded American Frances Tiafoe 6-3 6-4 while defending champion Alexander Zverev defeated Hubert Hurkacz 3-6 6-4 6-4.
'It's special, awesome to see' - Laver and Federer get standing ovations at Laver Cup
'Huge cheer straight away' - Federer gets standing ovation at Laver Cup