Wawrinka had to quit after just over two hours as he trailed Spanish fifth seed Feliciano Lopez 6-4, 2-6, 4-3 after taking treatment before the start of the final game.
Top seed Federer lost on Thursday in straight sets to German Daniel Brands with the Swiss complaining of back spasms which had bothered him for more than a week.
Retirement was a bitter blow for Wawrinka, winner of the spring clay title in Lisbon and Madrid Masters finalist against Rafael Nadal.
"I can't say exactly when it happened," said the world number 10 of his back problem.
"I don't know exactly but I definitely felt something back there during training last week.
Ï'm so disappointed that it had to happen here in Gstaad, it almost seems like bad luck for me here.
"I have to get it looked at by doctors and then rest and take a decision on what to do next.
"This is a delicate part of the season: I'm playing well but I don't want to risk an injury, I'll just have to see how it responds to treatment," added Wawrinka.
Lopez will play a Saturday semi-final against Dutchman Robin Haase, a winner over Marcel Granollers of Spain 5-7, 6-3, 7-6 (7/5).
Victor Hanescu, the 2011 champion, ended the dream week of Brands with a 6-3, 6-4 quarter-final win on the high-altitude clay of this alpine village.
Brands took treatment on court three games into the second set on his way to his 70-minute loss.
Hanescu, ranked 54th to the 55 of Brands, won his 10th match at Gstaad, finishing with five aces and a break of serve per set.
Hanescu next faces sixth seed Mikhail Youzhny, a winner over fourth-seeded tournament debutant Juan Monaco 5-7, 6-4, 7-6 (9/7).
Monaco was playing his sixth quarter-final of the season, but was unable to stop Youzhny from reaching a second Gstaad semi-final in three years.
Wawrinka looked dodgy from the start against Lopez, 31, a 2006 finalist who won the first set with an ace and withstood a storm as his Swiss opponent fought back.
Wawrinka appeared in trouble after levelling at a set apiece with Lopez having saved six set points in the second set.
The Swiss dropped serve for 1-2 on back-to-back double-faults in the third set as his conditioning began to worsen.
Lopez was fully in control by the time Wawrinka called for the trainer after the seventh game.
He gave up two points into the next game, with Lopez improving to 20-11 this season.
Results from day five of the ATP Swiss Open in Gstaad on Friday (x denotes seeding):
Victor Hanescu (ROM) bt Daniel Brands (GER) 6-3, 6-4
Mikhail Youzhny (RUS x6) bt Juan Monaco (ARG x4) 5-7, 6-4, 7-6 (9/7)
Robin Haase (NED) bt Marcel Granollers (ESP) 5-7, 6-3, 7-6 (7/5)
Feliciano Lopez (ESP x5) bt Stanislas Wawrinka (SUI x2) 6-4, 2-6, 4-3 - retired