Murray struggled to overcome Gilles Muller in the last 32 on Wednesday and after a inconsistent start, he took control of the first set against Ramos-Vinola racing away from 2-2 to take it 6-2.
But the 29-year-old Spaniard hit back to win the the second set by the same score. At 4-0 up in the decider, it appeared that Murray had restored the natural order. But instead of accepting his fate, Ramos-Vinola clawed his way back into the tie and took it on his second match point.
The top half of the draw was opened even wider when third seed Stan Wawrinka lost in straight sets to Pablo Cuevas. The 31-year old Uruguayan saw off the 2014 champion 6-4 6-4.
He will next play the Frenchman Lucas Pouille who advanced to the last eight following the abandonment of compatriot Adrian Mannarino 11 minutes into their match.
"I could barely walk let alone run," said Mannarino who beat 10th seed Jo-Wilfried Tsonga on Tuesday. "It's frustrating because I've been playing well but I'm not going to feel sorry for myself," the 28-year-old added.
Fifth seed Marin Cilic advanced to the quarter finals with a straight sets victory over the Czech Tomas Berdych. The 28-year-old Croat has yet to drop a set at this year's tournament.