Dominic Thiem saved two match points on his way to producing a fantastic comeback win and knock out three-time former Madrid Open champion Roger Federer on Friday.
Thiem made it through to his third consecutive semi-final on the red dirt at La Caja Magica after battling back to win 3-6 7-6 (13-11) 6-4.
Federer made an electrifying start against the two-time former finalist, Thiem, in their mouthwatering tussle.
He surged into a 3-0 lead and the Swiss maestro didn't look back, sealing the set in 29 minutes with some swashbuckling tennis.
The second set was a lot tighter, although Thiem, the Indian Wells and Barcelona Open champion, was unable to solve the conundrum of how to break the Federer serve.
They had to be separated by a tie-break and it was a thriller full of drama with the 37-year-old Swiss unable to take advantage of two match points. Federer saved five set points to deny the Austrian, although he could not repel a sixth on Thiem's serve.
Thiem broke early in the decider, but Federer responded in typical fashion to make it 4-4. However, the 25-year-old broke in the very next game before successfully serving out the match after two hours and 10 minutes of enthralling action.
Top seed Djokovic reached the last four after his opponent Marin Cilic withdrew from the tournament because of food poisoning.
Cilic said he had a "terrible night" and would not be able to play in the clash against the top-ranked Djokovic.
Djokovic, seeking a third Madrid Open title, and his second of the season after winning the Australian Open will next face Thiem.
Rafael Nadal produced his best performance on clay this season to defeat Stan Wawrinka 6-1 6-2.
The 11-time French Open champion unusually arrived in the Spanish capital still looking for his first title of the year but it is unlikely to remain that way for long if he continues to play like this.
Wawrinka simply could not cope with the consistent excellent of Nadal, who will face Stefanos Tsitsipas for a place in the final.
Tsitsipas, who was brushed aside by Nadal at the Australian Open, claimed another notable victory by beating defending champion Alexander Zverev 7-5 3-6 6-2.