Madrid - Dominic Thiem saved two match points and ended the first chapter of Roger Federer's return to clay court tennis with a come-from-behind 3-6, 7-6 (13/11), 6-4 win and reach the Madrid Open semi-finals on Friday.
The 37-year-old Swiss had returned this week to the surface for the first time in three years - his last clay court match was a loss to Thiem in Rome in 2016.
While Federer was heading out, there were no such problems for top seed Novak Djokovic who made the last-four when Marin Cilic withdrew and Rafael Nadal, the second seed, who brushed aside Stan Wawrinka 6-1, 6-2.
Thiem, the 2018 Roland Garros runner-up and winner of the Barcelona title last month, prevailed in two hours 10 minutes against Federer having saved two match points in a 15-minute second set tie-break.
He will on Saturday face world number one Djokovic, who advanced on a walkover when Cilic pulled out with a stomach virus.
Five-time champion Nadal needed just over an hour to reach his 11th Madrid semi-final and will face Greek Stefanos Tsitsipas, a winner over defending champion Alexander Zverev by 7-5, 3-6, 6-2.
"It was a good match for me, Stan is not an easy opponent regardless of the scoreline," said Nadal after his 14th quarter-final in the last 15 years in the Spanish capital.
"I had to play good tennis and reach my best level."
Federer said he was happy to have made his clay court comeback.
"I feel very good about my game. I thought I had some good matches here," the 20-time Grand Slam champion said. "I feel good on the clay right now."
Federer now has the option to take up a wild card being held for him next week in Rome. Otherwise, his next clay event will be the French Open where he last played in 2015.
"The match was so close," said Austrian fifth seed Thiem who had also defeated Federer in the Indian Wells final in March. "I was really lucky to save the match points.
"Roger was playing unbelievable on the clay. I'm very, very happy to win. He is so special, maybe the best ever in tennis, he has something different.
"Every time you play him, every point is a big challenge."
In the final set, Thiem earned a break for 2-1 as Federer netted a backhand but the Swiss rallied to break back, 4-4.
The momentum fizzled out though and a game later Thiem broke again for 5-4 with a lob winner.
The Austrian served out his fourth victory in six matches against Federer a game later.
Meanwhile, Simona Halep closed in on a return to the top of the world rankings after beating Belinda Bencic 6-2, 6-7 (2/7), 6-0 to advance to the women's final.
Halep, currently number three in the world, will reclaim the number one ranking should she win her third title at the Caja Magica.
Bencic had defeated Halep in their last two matches, but the reigning French Open champion, who lifted the trophy in Madrid in 2016 and 2017, came through in just under two hours.
Halep will play Dutch seventh seed Kiki Bertens, a finalist in Madrid last year, who defeated 2017 US Open champion Sloane Stephens 6-2, 7-5.
"It's such a nice feeling to be back in the final here. I really enjoy playing in Madrid, it motivates me," Halep said.
Results from the ATP and WTA tournaments in Madrid on Friday (x denotes seeding):
Novak Djokovic (SRB x1) bt Marin Cilic (CRO x9) - walkover
Dominic Thiem (AUT x5) bt Roger Federer (SUI x4) 3-6, 7-6 (13/11), 6-4
Stefanos Tsitsipas (GRE x8) bt Alexander Zverev (GER x3) 7-5, 3-6, 6-2
Rafael Nadal (ESP x2) bt Stan Wawrinka (SUI) 6-1, 6-2
Simona Halep (ROM x3) bt Belinda Bencic (SUI) 6-2, 6-7 (2/7), 6-0
Kiki Bertens (NED x7) bt Sloane Stephens (USA x8) 6-2, 7-5