In the match on Friday, the fifth-ranked Thiem was able to weather the storm against the 37-year-old Swiss great, who had reached the quarterfinals in his first appearance in four years at this ATP Tour Masters 1000 clay-court event and came out on fire with ultra-aggressive tactics in the first set, Efe news reported.
Not wanting to get into long, punishing rallies with his 25-year-old opponent, Federer mixed in some of the serve-and-volley tennis he had employed in recording his 1,200th career victory in Thursday's round of 16 against Frenchman Gael Monfils.
The world No. 3's aggressive strategy proved to be effective early on, as the Swiss put a sky-high 84 percent of his first serves in play in the first set, controlled play from the center of the court and sent Thiem scrambling to chase down balls from side to side.
Thiem, meanwhile, returned poorly at the start of the contest and also was caught off balance by the return game of Federer, who used short slices and drop shots to jerk the Austrian out of position.
In the second set, Thiem improved his return game and managed to draw Federer into more traditional clay-court rallies that stymied his aggressiveness, but the Swiss still fended off all five break points he faced to force a tiebreaker.
The match was essentially decided in the "breaker", in which Federer raced out to a 3-0 lead before Thiem battled back to gain a first set point with Federer serving down 4-6.
Thiem then had a chance to wrap up the set when he stepped to the line at 6-5, but Federer saved that second set point with a drop-shot winner and then a third at 6-7 when a Thiem forehand went wide.
Both of the Swiss' match points came with Thiem serving - down 7-8 and then trailing 9-10, with Federer missing a forehand return on the first one and Thiem striking a forehand winner on the second.
The Austrian then finally clinched victory in the tiebreaker on the 24th point, setting up his sixth set point with a forehand return winner against a Federer serve-and-volley play before tying the match at a set apiece with an overhead winner.
In the third set, Federer finally started losing steam on his service games.
Although he was able to break back after losing serve for the first time in the third game of the third set, Thiem got one last crucial break of serve in the ninth game of the decider and then served the match out one game later.
Federer, who staved off two match points on Thursday in his three-set victory over Monfils, said he did not enjoy getting a taste of his own medicine.
"(It's) frustrating, clearly," Federer was quoted as saying on the ATP Tour's Web site "Losing with match points is the worst, so that's how I feel. But nevertheless, if I take a step back, it's all good. I had a great week."
Federer, who has avoided clay in recent years to avoid excessive wear-and-tear on his body and prolong his storied career, had not played an ATP tournament on tennis' slowest surface since 2016.
Thiem, for his part, said he realizes that despite the win over Federer, winner of a record 20 Grand Slam men's singles titles, he still faces a daunting path to the title.
The Austrian will take on Serbian world No. 1 and 15-time Grand Slam champion Novak Djokovic in Saturday's semifinals and then could face Spanish world No. 2 and 17-time major champion Rafael Nadal in Sunday's final.
"The test today was huge and tomorrow is a different game, of course," Thiem said. "But I was playing Novak last year, and two years ago, and he was not at his best, I guess. Now he is again. He's won the last three Grand Slams and he is at the top of the ATP ranking again. So the challenge couldn't be bigger."
Besides Federer and Djokovic, two other past winners of the French Open, tennis' biggest clay court event, are still alive in Madrid and will face off in Friday's last men's quarterfinal: 11-time Roland Garros champion Nadal and Switzerland's Stan Wawrinka.
The other men's singles quarterfinal pits two of tennis' rising stars, Greek world No. 9 Stefanos Tsitsipas and German world No. 4 and defending Madrid Open champion Alexander Zverev. (IANS)