The 10th seed served for the match on three occasions and looked certain to book a place in his first-ever Grand Slam semi-final.
Almagro - who had not beaten his compatriot in 12 previous attempts - does not think that he choked.
"I don't want to think that it's a mentality problem," said Almagro. "If I have a mentality problem, I think I didn't win the first two sets.
"I don't know what's wrong. I think I played a really good match. It was close. It was a great battle. At the end it was really tough because I just started to feel some things at 4-3 in the third set on my ankle and on my adductor.
"After that it was really tough and he started to play better and better, and he is the winner."
Almagro has never been beyond the quarter-final of any Grand Slam tournament.