Almagro dominated the first two sets and was serving for the match in the third when Ferrer bounced back, breaking in the crucial 10th game and then breaking his Davis Cup teammate again.
The fourth set featured eight service breaks until Ferrer finally took control in a tiebreaker to force a fifth set.
Almagro has played 33 consecutive majors, but never reached a semi-final. It was his first Grand Slam quarter-final on any surface other than clay — he has reached three quarter-finals at the French Open — and he really took the match to Ferrer, the leading Spaniard in the tournament in the absence of 11-time major winner Rafael Nadal.
Almagro hurt his left leg late in the fourth set and needed a medical timeout before the fifth. After holding serve in a long game to open the fifth set, he quickly wilted after the first break.
On the last point, he hit a service return back into play and had already started strolling to the net as Ferrer prepared to hit the winner.
As he left the court, he gave his compatriot a friendly pat on the back as Ferrer packed his bag on the courtside chairs, then left Rod Laver Arena.
“In the important moments, I played more consistent in my game,” Ferrer said. “Of course, in the next round, the semi-finals, I need to play my best tennis, better than today.”
Today, the other side of the men’s singles draw has second seed Roger Federer playing Jo-Wilfried Tsonga and No. 3 Andy Murray taking on Jeremy Chardy of France.