Monfils, 28, was trying to reach his second career Grand Slam semifinal. Instead, Federer advanced to his 36th, ninth at Flushing Meadows. Five of Federer's major titles came at the US Open from 2004-08, but he exited in the quarterfinals in 2012, and the fourth round in 2013.
On Saturday, the second-seeded Federer will play 14th-seeded Marin Cilic of Croatia. The other semifinal will be No 1 Novak Djokovic against No 10 Kei Nishikori.
Cilic wasn't allowed to play in last year's US Open, forced to the sideline by a four-month doping suspension that he says he didn't deserve. But Cilic reached the second Grand Slam semifinal of his career, and first since 2010, by beating sixth-seeded Tomas Berdych of the Czech Republic 6-2, 6-4, 7-6 (4) Thursday.
It took Monfils 78 minutes to build a two-set lead, shaking of a twisted right ankle that left him down on the court. It helped that Federer made 26 unforced errors in that span.
And as if all he had to do was want to improve his play, Federer did. He suddenly was remarkably cleaner, with only one unforced error in the third set, and two in the fifth.
Attacking the net helped: Over the final three sets, Federer earned the point on 34 of 46 trips forward.
"I knew I could play better after the first couple of sets," Federer said. "I believed I could turn it around from the get-go when the third set started."
Monfils is nothing if not unpredictable. In an era where some men, including Federer, have two coaches, Monfils goes without any. He'll admit to tanking points, games or entire sets. He sips sodas during matches, including Thursday. He'll go for a between-the-legs shot when a mundane forehand would do.
Make no mistake, though. This was not easy. The turnaround might not have been possible for Federer a year ago, when he was dealing with a bad back and trying to figure out whether he should switch to a larger racket head.
But now Federer, however old, is approaching his skills of old. He got to the finals at his previous four tournaments - including a loss to Djokovic in Wimbledon's title match in July - the first such run by a 30-something since Ivan Lendl in 1990. One more victory, and Federer's final streak will stretch to five in a row.