But Wawrinka dug in to save eight break points - he saved 22 of 27 in the match - and then took his second match point when the umpire confirmed a backhand had caught the edge of the line.
"Very pleased how I'm feeling and how I'm playing, and still trying to stay true to playing freely and with nothing to lose", Federer, trying to repeat his 2009 title run having missed the last three French Opens, told reporters.
Roger Federer became the oldest man to reach the French Open fourth round in 47 years on Friday by winning his record 400th Grand Slam match in straight sets against Norwegian Casper Ruud, while women's second seed Karolina Pliskova was dumped out.
Wawrinka prevailed in a match that lasted over five hours and he will face Roger Federer next in the quarter-finals on Tuesday.
Federer, who is yet to drop a set in the tournament, said he still remembers his last-eight loss to Wawrinka in Paris four years ago.
On Saturday, Japanese star Osaka's bid for a third successive Grand Slam title found an underwhelming conclusion with an erratic display in defeat by Katerina Siniakova, before Williams crashed out in similarly poor fashion to fellow American Sofia Kenin.
Dominic Thiem accuses Serena Williams of 'bad personality' in press conference kerfuffle
Roger Federer , meanwhile, leapt to the defence of Thiem , describing him as "a superstar, a male superstar". What the hell, I don't care. "I would have been jumping off the couch back then".
"I was prepared for the worst scenario, losing in the first round in three sets".
World No 2 Rafael Nadal was furious Kyrgios chose to execute the shot against him at the Mexican Open earlier this year.
"I have a bad memory of it. Stan beat me in three sets with his awful shorts", said Federer in reference to his compatriot's gaudy, checked shorts, compared by some to a tablecloth pattern.
That was also the last year Federer played at Roland Garros, before taking the decision to skip clay entirely until returning to the surface this year.
"I hope he's not at the level of '15, but we'll find out, because there he was crushing the ball".
"Totally possible. I don't think I would use it but I have thought about it many times", Federer said. "Juan is a very good player so I congratulate him and his team", said Nadal.
British number one Johanna Konta also continued her comfortable progress through the draw by seeing off Croatia's Donna Vekic in straight sets to reach her first Grand Slam quarter-final since Wimbledon in 2017.