Ramos-Vinolas beat the world No 1 on Murray's return from an elbow injury in the third round of the Monte Carlo Masters last week, and he looked poised for a repeat.
But Ramos-Vinolas missed a chance to serve for the match and it was Murray who came through 2-6 6-4 7-6 (7-4) in a little under three hours.
In the semi-finals he will face fourth seed Dominic Thiem, who will be looking for a third British scalp of the week after knocking out Kyle Edmund and Dan Evans.