(CNN) -- Jurgen Melzer battled back from two sets down at the French Open to beat Novak Djokovic in a four-hour epic and book his first ever appearance in a Grand Slam semifinal.
The 29-year-old Austrian eventually triumphed 3-6 2-6 6-2 7-6 6-4 in front of a rapturous crowd to set up a clash with Rafael Nadal.
Melzer looked to be heading for a swift exit, winning just five games as the number three seed powered his way to the opening two sets.
Djokovic went a break up in the third but, from nowhere, Melzer launched an incredible fight back to take the set 6-2.
The fourth went to a tie break but Melzer won it 7-3 to take the match into a deciding set.
If anything the standard of tennis improved in the fifth as Djokovic unleashed a string of fiery forehands, with Melzer utilizing his drop shot to good effect.
With the set level at 4-4 Melzer finally broke his opponent's serve, but in the next game Djokovic thought he had gone 0-30 up before his passing shot was controversially overturned by the umpire.
The Serb saved two match points but Melzer eventually sealed his passage to a first ever semifinal at a major championship.
"I told myself, 'It's my first quarter-finals in my life in a Grand Slam, just don't go away. Just don't make it easy for him. Fight as much as you can'," Melzer told a press conference.
"And I wasn't playing so bad, I just missed a lot of easy shots when I had the chance and the opportunity to finish the point. After that I got back in, and at 2-2 in the third it was an open match. I think I got a little under his skin after the third set."
Melzer will face four-time champion Rafael Nadal who is on course to regain his French Open crown after easing past fellow Spaniard Nicolas Almagro.
Nadal went through in straight sets, recording a 7-6 7-6 6-4 victory in two hours 34 minutes at Roland Garros.
Almagro sped out of the blocks on Court Philippe Chatrier, racing into a 3-0 lead in the opening set, but Nadal recovered a break to level the match at 3-3.
Nadal eventually clinched the set 7-2 in a tie break. The second set offered up only one break point -- Nadal saving it -- before the world number two triumphed 7-3 in the tie break.
Almagro held on until 4-4 in the third set before Nadal broke his serve to love, the world number two sealing the match in the next game.