David Ferrer needed all his fighting qualities to come out on top of an enthralling all-Spanish encounter with Nicolas Almagro at the Australian Open.
Ferrer, the fourth seed, had been on the brink of defeat in the third and fourth sets before progressing 4-6 4-6 7-5 7-6 (7-4) 6-2 after three hours 44 minutes.
He will face defending champion Novak Djokovic in the semi-final.
Almagro, ranked 10th in Melbourne, must have thought he was on course for his first grand slam semi-final appearance as he raced through the first two sets and then led 5-3 in the third.
Ferrer, though, has never lost to his compatriot and rattled off four games on the bounce to keep alive his hopes.
An extraordinary fourth set saw both players struggle to retain their own serve - with eight breaks in total. Crucially for Ferrer, he was able to level the match when 5-4 and 6-5 down before going on to clinch the tiebreak.
The pressure and exertions were beginning to take their toll on Almagro, who was forced called for the trainer between sets.
And Ferrer took full advantage as he broke Almagro in the fifth and seventh games before serving out for the match.
"It was a miracle I won this match," Ferrer said. "I tried to fight and do my best but I need to play better than today in the next round."
"I think maybe this time I was very close to losing but I am positive. I am in the semi-final. I think the tie-break of the fourth set I played very well.
"And in the fifth, he was cramping, problems with his leg, so it was easier for me."
Ferrer admits victory over Djokovic would represent a huge shock.
"'Nole' is a special player," he said. "He has every shot. He's the best, I think.
"He's the number one of the world and he's the favourite to win the Australian Open. Anyway I will have to play better than today for to win, for sure."