Argentinian Pablo Cuevas summoned something special to turn around his Madrid Open quarter-final match with Alexander Zverev and claim a 3-6 6-0 6-4 win.
It was in the second set that he produced his best tennis, including what may well have to go down as the shot of the year.
With his back turned and standing well beyond the baseline, he came up with a miraculous winner to leave his German opponent stunned en route to a second-set bagel.
He will take on Thiem next after the Austrian won 6-1 6-4 against Coric, who saw off world number one Murray in straight sets.
Elsewhere, a wrist injury ended Nishikori's involvement in Spain, sparing 2016 winner Djokovic the rigours of a last-eight meeting.
The Serbian, who recently split from his entire coaching team in a bid to revive his flagging fortunes, is trying to chase down Murray at the summit of the world rankings.
And defending his Madrid title will keep that bid on track after Murray's early exit.
It is the first time the 12-time grand slam winner has got past the quarter-finals this year since losing to Murray in January's Qatar Open final.
Djokovic will now face Nadal in the semis with the Spaniard yet to lose a singles match on clay this year.