The 37-year-old Swiss beat his compatriot 7-6 (7/4), 4-6, 7-6 (7/5), 6-4 to reach his 43rd major semi-final and eighth at Roland Garros.
Defending champion Nadal, bidding for a 12th title at the French Open, blitzed a weary Kei Nishikori 6-1, 6-1, 6-3.
Federer trails his head-to-head record with Nadal 23-15 – despite winning their last five matches – and 13-2 on clay.
The Spaniard has a 5-0 stranglehold over Federer at Roland Garros with Nadal winning their most recent Paris clash in the 2011 final.
“The complete dream would be to win the tournament,” said Federer. “Other players won’t agree. It will be difficult, but I believe it anyway.”
The 20-time Grand Slam champion is the oldest man to make the semis at one of the big four tournaments since Jimmy Connors at the 1991 US Open aged 39.
Wawrinka saved 16 of 18 break points in a thrilling encounter, but Federer quickly finished off the match after a rain delay to progress.
It is the third seed’s first appearance at the French Open since 2015 after taking time away from clay to focus on Wimbledon, but he has been in fine form in Paris and has only lost one set so far – as has Nadal.
Nadal, who turned 33 on Monday, is three behind Federer in the all-time list of Grand Slam singles titles heading into their 39th career clash.
It will be Federer’s first Roland Garros semi-final since a defeat by Novak Djokovic in 2012.
The 2009 French Open champion struck 53 winners on Tuesday, as Wawrinka’s 61 unforced errors proved costly.
In a dramatic opening set on Court Suzanne Lenglen, Federer saved four break points before taking it in a tie-break.
Wawrinka had saved 22 of 27 break points in his epic last-16 victory over Stefanos Tsitsipas, including all eight in the deciding set, and he was at it again on Tuesday, making it seven from seven to move 3-1 in front in the second.
He suffered from a few jitters when serving to level the match, but took his fourth set point.
The topsy-turvy nature of the encounter continued in the third set, as Federer missed two set points before salvaging two break points himself after the players had earlier traded breaks.
Wawrinka held his nerve to force the quarter-final’s second tie-break, but Federer moved two sets to one in front on his fifth set point.
After the threat of thunderstorms and dark skies forced the players from the court with the fourth set level at 3-3, Federer returned refreshed 80 minutes later and sealed a 23rd victory over Wawrinka in their 26th meeting, despite needing three match points to get over the line.
Nadal took his record in Paris to 91 wins and just two defeats after a one-sided contest with Nishikori to reach his 31st Slam semi-final.
“It’s a great satisfaction to be in another semi-final, there are lots of emotions,” said Nadal.
“My level has been very good throughout the tournament and I am happy to be able to come back and play another day.”
Tuesday’s win was Nadal’s 11th in 13 meetings against Japanese seventh seed Nishikori who had played back-to-back five-setters to reach his third quarter-final at Roland Garros.
The 29-year-old Nishikori managed just nine winners in total in the first two sets.
As the skies darkened over the city, so did Nishikori’s mood as he slipped 4-1 down in the third.
Even the weather delay didn’t help as Nadal needed just another eight minutes to finish the job.
Johanna Konta became the first British woman in 36 years to reach the semi-finals by sweeping past seventh-seeded Sloane Stephens, last year’s runner-up, 6-1, 6-4 to set up a tie against Czech teenager Marketa Vondrousova.
The 28-year-old Konta had not won a match at Roland Garros in any of her previous four visits.
But now she has emulated Jo Durie who was the last British woman to make the French Open semi-finals in 1983.
“I’ve always said that whenever I step out onto the court, I’m always going to have a chance. I’m always going to have a shot,” said Konta.
The 19-year-old Vondrousova battled past Croatian 31st Petra Martic 7-6 (7/1), 7-5.
“She had beaten me four times before but I think Roland Garros must be my lucky place,” said the Czech after securing victory on a fourth match point.