The stirring comeback win marks the ninth time in his career Federer has rallied from two sets down to snatch victory, setting up a final-four meeting with 14th seed Marin Cilic.
Frenchman Monfils struck a backhand long to squander his first chance to claim victory and then Federer denied the 20th seed with a sizzling forehand winner to stay in the match.
From that point on, Federer took charge by holding serve for 5-5, closing out the fourth set and then breaking Monfils in the first game of the fifth.
Playing at his brilliant best after scattering unforced errors earlier in the match, the Swiss master took nine of the last 11 games in the three-hour 20-minute clash at Arthur Ashe Stadium.
Federer said he kept a positive attitude despite falling behind.
"I still thought the finish line was far for Gael," Federer told the stadium crowd. "I knew I could play better tennis.
"When I was down two match points, I wasn't feeling so great ... I thought 'this is it, this is the last point, man. Just go down fighting, don't miss an easy shot and let him have it.'
"I served well and stayed in the match and somehow turned it around. I felt great in the fifth, though. I started playing better and better as the match went on. It's a great feeling."
Federer, a near perfect 25-1 playing under the floodlights of Arthur Ashe Stadium court, must have wondered which Monfils would show up on Thursday.
Labelled one of the game's great natural talents, Monfils can be wildly entertaining or maddening, depending on his mood and the near capacity crowd saw both sides of the 28-year-old Frenchman during a riveting the three hour, 20 minute encounter.
Monfils added several highlight reel shots to his collection in winning the first two sets, and after Federer won the third he carved out two match points in the fourth.
But with Federer on the ropes the 20th seeded Frenchman could not deliver the knockout punch - and after misfiring most of the night, Federer slowly began to find his mark. He seized his chance when it arrived, holding serve for 5-5 to close out the fourth set and then breaking Monfils in the first game of the fifth.
"It was one of those moments where you got the back against the wall and hope to get a bit lucky and you hope to play exactly the right shots that you need or that he completely just messes it up," said the 33-year-old Swiss.
"Either way works as long as you get out of it. It's just unbelievable to win matches like this at slams.
"I'm not sure I have ever saved match point before in a slam. If that hasn't happened, I'm unbelievably happy that it was today."
Federer's next opponent, 14th seed Cilic, blasted his way past sixth seed Tomas Berdych 6-2 6-4 7-6(4).
Gael Monfils (R) of France and Roger Federer of Switzerland hug after Federer won their five set quarter-final …
- Sports & Recreation