A wounded Novak Djokovic was beaten in three sets by Grigor Dimitrov in the second round of the Madrid Open.
Dimitrov, the world number 28, received a standing ovation from the crowd after defying cramp problems to prevail 7-6 6-7 6-3 in three hours and four minutes.
World number one Djokovic dropped the opening set 8-6 in a tie-break and needed a medical timeout when trailing 4-2 in the second after tweaking his right ankle.
The Serb injured the same joint while on Davis Cup duty in April but, after some extra taping was added by the trainer, he opted to carry on and broke back straight away.
Djokovic saved a match point in the subsequent tie-break before taking it 10-8 on his third set point to level things up as his opponent struggled with cramp.
But Dimitrov, 21, regrouped to dominate the decider, breaking in the opening game and then again to seal the biggest victory of his career.
The Bulgarian will play either 15th-seeded Swiss Stanislas Wawrinka or Colombia's Santiago Giraldo in the last 16.
Also on Tuesday, Frenchman Gilles Simon saw off countryman Jeremy Chardy 6-4 7-6 (7/5) in their second-round contest. His reward is a clash with Andy Murray, who saw off Florian Mayer in straight sets.
Seeds Richard Gasquet (eight), Janko Tipsarevic (nine) and Milos Raonic (12) were all beaten, while Benoit Paire earned a second-round clash with Rafael Nadal thanks to a 6-1 7-6 (7/0) win over Joao Souza.