The world number one started his second-round match against Gilles Muller on Wednesday with three double faults in the first four points of the match and it did not get much better in his match-up against the clay-specialist.
Murray was broken seven times during a see-saw encounter with the Spaniard and was leading 4-0 in the final set before he suffered a spectacular collapse.
Ramos-Vinolas rallied back to take the next four games to level the decider and despite the Scot taking the ninth to go 5-4 up, the 15th seed closed out the match with three successive games to seal an unlikely victory.
Murray needed seven minutes to hold on to the opener before he was broken on his next two service games in the first set, as the elbow injury that saw him miss over a month of action looked to be having an impact.
Luckily for the Scot, he dictated the 15th seed's serve throughout the opening set with three breaks of his own to take it 6-2, with neither player showing signs of fluency.
Murray endured another lengthy opening service game at the beginning of the second set to nudge 1-0 up before Ramos-Vinolas held for the first time in the match to level the scores and kickstart his revival.
The Spaniard converted the second of two break points in the third game to go ahead before holding to love in his next service game to open up a 3-1 lead.
Ramos-Vinolas produced a wonderful lob in the opening point of game five to put Murray under pressure but the Scot responded to reduce the arrears.
The Barcelona-born player held to love in the next as he became more dominant at the baseline and earned himself two more break points after a double fault from Murray, before the world number one dumped a forehand into the net to gift Ramos-Vinolas a 5-2 advantage, which he seized upon by serving out the set.
Losing the second set seemed to ignite Murray as he reeled off the opening four games of the decider, which included two more breaks of the Ramos-Vinalos serve, and he looked to be heading towards a comfortable victory.
The Spaniard stopped the rot as Murray dropped his serve for the fifth time to reduce the scores to 4-1 before the Scot fell away.
Ramos-Vinolas rallied back to take the next three games to restore parity, which included his sixth break of the clash, before Murray found himself trailing 0-40 on his serve in the ninth game.
He managed to take six consecutive points to re-establish the lead but he was powerless from stopping the resurgent Ramos-Vinolas from sealing the next three games to secure a quarter-final berth against fifth-seed Marin Cilic.
Additional reporting by the Press Association.