By Martyn Herman
The Serbian third seed was cruising after pocketing the first two sets with razor-sharp tennis but the wheels fell off when he led 2-0 in the third and he slumped to a demoralizing 3-6 2-6 6-2 7-6 6-4 defeat in more than four hours.
When 22nd-seed Melzer served for the match at 5-4 in the fifth he fluffed a forehand and appeared to have been wrong-footed by a Djokovic crosscourt as he approached the net.
The ball appeared to have touched the line but when Melzer asked the umpire to climb off his chair and inspect the mark, Carlos Bernardes deemed that it had landed out meaning that instead of being down 0-30 the Austrian was back at 15-15.
Djokovic could not believe his eyes and was still chuntering about the decision after the match, although he only had himself to blame for wasting the chance to face Rafael Nadal in the semi-finals.
"From my side and from my perspective, it was looking good," the 23-year-old former Australian Open champion told reporters. "There was no space between the line and the mark, and that means the ball is good.
"I don't know why the chair umpire got that decision wrong. And there was another ball on 4-4, my advantage, as well, and the ball was out. But this is all part of the sport."
The French Open does not allow HawkEye challenges which are used at the three other grand slams as there is normally telling evidence of where the ball landed on the red clay dust.
"I don't know what was going on with him, but the ball was looking good from everywhere. I can't blame him for losing this match. That's one call. But maybe if that call went in my favor maybe I would break him on that, it would be 0-30 and he would feel a little pressure."
More worrying for Djokovic, aiming to reach his third Roland Garros semi-final in four years, was his sudden collapse in the third set when he became jaded.
"I made a big mistake," he said. "I made him come back into the match with my unforced errors and then he caught the momentum and he was playing really well."
(Editing by Osmond)