Rafael Nadal’s run at the Madrid Open came to a screeching halt after he was outgunned in a straight-sets loss by Jiri Lehecka.

The Czech, seeded 30th, fired off 33 winners to his opponent’s 14 and broke Nadal’s serve in either set to claim a 7-5 6-4 victory in the last 16, dashing the hopes of a partisan crowd at the Caja Magica.

Nadal’s first defeat to a player ranked outside the world’s top 20 on his beloved clay marks his final appearance in the Spanish capital, where he has won the tournament a record five times.

“I had the opportunity to play one more time here on this court,” said Nadal afterwards. “It was a very special week for me, very positive and very emotional.”

Nadal had a gloomy outlook about his physical condition before competing in Madrid and even cast doubt on appearing at the French Open but he can take some solace from his run to the fourth round.

He thrashed 16-year-old Darwin Blanch for the loss of one game then avenged his defeat in Barcelona to 10th seed Alex de Minaur before winning a titanic three-hour tussle against Argentina’s Pedro Cachin.

He has not looked at his best all tournament and that was the case here too, with his serve once again lacking firepower, but there was nothing to separate him from Lehecka in the first 10 games.

But Lehecka broke to love in the 11th before serving out to take a one-set lead, and Nadal again dropped serve at the start of the second.

While Nadal attempted to use his looping top-spin forehand to claw his way back into the match, he was unable to impose himself on the serve of Lehecka, who faced and saved just one break point.

Lehecka’s victory in a little more than two hours was greeted in near-silence before the crowd at Manolo Santana Stadium rose to acclaim Nadal in a post-match presentation ceremony.

As well as being handed a special trophy, five banners above the stands were unfurled – signifying the years he won the tournament – with the words “Gracias Rafa”.

“All I can say is thank you to everyone that has helped me in my career – it hasn’t finished yet,” added Nadal, who is expected to head to Rome to compete in the Italian Open which starts next week.