MADRID — Rafael Nadal has found a worthy rival on clay.

Dominic Thiem beat the top-ranked Nadal 7-5, 6-3 in the Madrid Open quarterfinals on Friday, breaking the defending champion's run of 21 straight wins on clay courts.

Nadal hadn't lost a single set on clay since falling to Thiem a year ago in the Italian Open quarterfinals.

But Thiem succeeded in doing the nearly impossible with his deep drives: Make Nadal look sluggish and a step slow on clay.

Nadal will lose his world No. 1 ranking to Roger Federer because of the defeat.

"Of course I am disappointed," Nadal said. "I tried to fight back but I wasn't good enough and he was better. Dominic has a lot of potential. Whenever he plays really well, it is difficult to stop him."

Since last year's loss to Thiem, Nadal had been impeccable on his preferred surface. He won the French Open and the hard-court U.S. Open to take his Grand Slam haul to 16, and he came to the Spanish capital fresh off winning his 11th titles at both Monte Carlo and Barcelona.

Nadal, however, said the loss was not a reason to doubt his chances to add to his 10 French Open titles in the coming weeks.

"I won 50 straight sets on this surface," he said. "Today I lost the match. It was not my day. But that is part of the sport. So I can't go back to my hotel and think that I have to do a lot of things different to prepare for the next events because that wouldn't be smart."

Nadal brushed aside Thiem 6-0, 6-2 just three weeks ago at Monte Carlo, where the Austrian was returning after being sidelined for a month due to a broken foot.

Thiem was in stellar form at Madrid's Caja Magica. He got the better of long rallies by hitting precise winners, and avoided the costly errors that sunk Nadal's title defence.

"He always had position to move around and to play a good shot, to strike the ball in a comfortable position," Nadal said. "It's difficult to harm a player like him because he is very powerful, he strikes the ball very hard."

The fifth-seeded Thiem avenged his loss to Nadal here in last year's final, and earned his third career victory in nine meetings with Nadal, all on clay.

"It's one of the toughest things to do to beat Rafa on clay," Thiem said. "It's so special, amazing, in his home country and in his living room in Madrid. It was an amazing match."

Thiem will face sixth-seeded Kevin Anderson in the semifinals after he hit 15 aces to down Dusan Lajovic 7-6 (3), 3-6, 6-3.

Nadal said on Thursday, after breaking John McEnroe's 1984 record for sets won on the same surface by winning his 50th straight set on clay, that he expected the match against Thiem to be "key to this tournament."

He was right to be worried.

Thiem unsettled Nadal from the start, breaking his serve twice in the first set.

Nadal appeared to have salvaged the opening set when he broke Thiem back for 5-5, but the Austrian took the advantage right back after Nadal sent a forehand into the net.

Thiem then struck an ace to complete the set.

His shirt drenched in sweat, Nadal looked stunned in the second set when he sent four serves in a row into the net for back-to-back double faults before he ceded another break to go down 2-1.

Nadal pulled back a break, but couldn't defend his serve and Thiem broke him twice more, finishing off the world No. 1 with one final forehand winner.

"If you want to beat him, especially on clay, you have to do something special. If I had played normal I would have no chance," Thiem said. "I had to go for shots and go down the line and everything worked today. To beat Rafa on clay you have to have a special day."

Second-seeded Alexander Zverev beat seventh-seeded John Isner 6-4, 7-5 to also advance.

Zverev will face Denis Shapovalov after he outlasted Kyle Edmund 7-5, 6-7 (6), 6-4.

On the women's side, two-time former Madrid champion Petra Kvitova beat Karolina Pliskova 7-6 (4), 6-3, in an all-Czech semifinal.

Kvitova will meet Kiki Bertens in the final after she beat seventh-seeded Caroline Garcia 6-2, 6-2.