Federer dropped a set for the first time in this year's tournament, but eventually emerged unscathed on Wimbledon's showpiece arena just hours after defending champion Andy Murray had walked off, stunned by his quarterfinal defeat against Grigor Dimitrov.
Murray's loss was the latest in a long line of shocks on Centre Court over the last nine days, with world number one Rafael Nadal and former Wimbledon champion Maria Sharapova also among those bowing out.
But fourth seed Federer ensured his name wasn't added to the list with a come-from-behind victory in the last eight to secure his 35th Grand Slam semifinal appearance.
It was also the 17-time Grand Slam champion's 72nd match victory at the All England Club, which moved him into second place on the all-time list ahead of Boris Becker and behind only Jimmy Connors.
The 32-year-old, bidding to become the first man to win eight Wimbledon singles titles, was to face Australian wild card Nick Kyrgios or Canadian eighth seed Milos Raonic for a place in final.
"It's always nice to play on Centre Court and in England, I have had amazing support since I first came in 1998," said Federer.
"Stan played great in the first two sets but maybe he struggled with his fitness a little," he said.
"We know our patterns so well so it's hard to get by."
Federer admitted he has been especially motivated at Wimbledon this year following his surprise second round loss to Sergiy Stakhovsky 12 months ago.
"Last year was a disappointment as Wimbledon is always a highlight of the year for me," the Basel native said.
"I didn't come close and I was very deflated," he added.
"So it's good to come back and have a chance of going further."
Federer had been in imperious form as he swept through the first four rounds without dropping his serve for the loss of only 32 games.
But Wawrinka represented a significantly tougher test than the likes of Gilles Muller and Santiago Giraldo.
The 29-year-old had already replaced Federer as the Swiss number one earlier this year and defeated his close friend in the Monte Carlo final in April.
That was only his second win against Federer in 15 attempts, but any inferiority complex about facing him had long disappeared.
Wawrinka was quickly into his stride on Centre Court as he broke for a 4-1 lead.
With Federer unable to make any impact on the Wawrinka serve, that was enough to take the first set.
But Federer turned the tide, keeping his cool in a tight second set tie-break to level the match.
Federer was beginning to hit peak form and Wawrinka, showing signs of fatigue in his third match in three days at the rain-hit tournament, couldn't muster a response when Federer broke in the third set.
Regardless of the gradual decline which has seen him win only one Grand Slam title in his last 17 attempts, Federer with the bit between his teeth at Wimbledon remains a formidable force.
He easily finished off the third set and kept the pressure on Wawrinka, drawing a crucial error to break for a 2-1 lead at the start of the fourth.
Wawrinka kept fighting and saved four match points at 4-5, but Federer finally delivered the knockout blow at the fifth attempt.