Novak Djokovic avoided a huge upset by coming from two sets down to beat Andreas Seppi, but the top seed will be concerned by his error-strewn display.
Djokovic's bid to become the first man since Rod Laver in 1969 to hold all four Grand Slam titles at the same time looked in tatters as he faced defeat.
But the world number one rallied to win 4-6 6-7 (5-7) 6-3 7-5 6-3.
Djokovic, chasing his first French Open title, will play Jo-Wilfried Tsonga or Stanislas Wawrinka in the last eight.
The Serb's hopes looked over for another year as 22nd seed Seppi deservedly won the first two sets.
But an out-of-sorts Djokovic dug deep to overturn a two-set deficit for only the third time in his Grand Slam career.
"I played very badly, but I won thanks to my fighting spirit," said Djokovic after a 25th successive Grand Slam match victory.
"He was the better player for the first two sets and I was fortunate to come through. But even at two sets down I still believed I could do it and that's about the only positive I can take. It was one of those days when nothing worked."
The result - which took four hours and 18 minutes - seemed a distant prospect when Seppi fought back from 3-0 down to snatch the first set.
Djokovic was looking lethargic on a damp and overcast day at Roland Garros, and Seppi took advantage by breaking in game five and then holding to love for a 4-2 lead.
Djokovic struck back to force a tie-break but could not raise his level and a netted forehand left him in big trouble.
Breaks were exchanged early in set three and after holding in game six, Seppi was three games from winning.
It was at that moment that he faltered, though, and Djokovic snapped up the set to keep his hopes alive.
Both men were making countless mistakes in an encounter that, for all its drama, lacked the quality expected by the crowd on Court Philippe Chatrier - the showpiece stage at Roland Garros.
Djokovic raced into a 3-0 lead in the fourth set but was duly pegged back, with Seppi saving four break points in game six.
But the top seed made made no mistake on his next opening, a brilliant crosscourt forehand pass helping him level the match at two sets all.
Seppi now looked deflated and while the occasional winner still came from his racquet, it was Djokovic whose play carried more purpose.
A double-fault gifted Djokovic a 4-2 lead in the decider and he saved a break-back point for 5-2 before serving out with a superb drive-volley.